Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xticks on figure #23

Open
kufton opened this issue Dec 20, 2022 · 1 comment
Open

xticks on figure #23

kufton opened this issue Dec 20, 2022 · 1 comment
Labels
enhancement New features, or improvements to existing features.

Comments

@kufton
Copy link

kufton commented Dec 20, 2022

Describe the bug

There seems to be no way to render a chart using pyplot.plot, you have to use the figure which doesn't allow for xticks or set_xticks.
I'm running into a block to label the data with custom tick labels as a result of this.

Steps to reproduce

I've got user generated data from a function that just records input to a sqlite db.

data = cursor.execute("SELECT * FROM emotion_tracking ORDER BY datetime DESC limit 20").fetchall()
       if data:
           dates = [len(data) - data.index(row) for row in data]
           print(dates)
           states = [row[1] for row in data]
           self.dates = np.array(dates)[::-1]
           self.states = np.array(states)[::-1]
           self.labels = self.dates
       self.data = data

I've organised it so that the most recent will be displayed on the right hand side of the chart

The chart is built using this function.

def draw_chart(self, chart, figure, *args, **kwargs):
       print("in draw chart")
       # Draw the chart
       ax = figure.add_subplot(1,1,1)
       # ax.set_xticks(rotation = 90)
       ax.plot(self.dates, self.states)
       ax.set_xlabel('Date')
       ax.set_ylabel('EQ Score')
       ax.set_title('Daily Average Emotions Over Time')

This displays the chart:

Screenshot 2022-12-20 at 5 08 41 pm

When I change it to use dates, we get a big mess.
Screenshot 2022-12-20 at 5 10 25 pm

I'm wanting to a aggregate the data (a numpy function I'm sure) but more importantly and the point of the ticket, display the days in a readable way, ideally roation=vertical.

Expected behavior

I was hoping to use plotly.plot but this creates a new window.
using add_sublot doesn't allow for xticks or set_xticks on a subplot.

Screenshots

No response

Environment

  • Operating System: Mac OS 12.2
  • Python version: 3.9.12
  • Software versions:
    • Briefcase:0.3.11
    • Toga:0.3.0.dev39
    • Toga_chart: 0.1.1

Logs


Additional context

No response

@kufton kufton added the bug A crash or error in behavior. label Dec 20, 2022
@freakboy3742 freakboy3742 added enhancement New features, or improvements to existing features. and removed bug A crash or error in behavior. labels Dec 22, 2022
@freakboy3742
Copy link
Member

Reassigning as an enhancement, not a bug; while pyplot.plot() may be a common API, it's not the API we've documented for toga-canvas.

Support for pyplot.plot() would certainly be nice to have, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, or improvements to existing features.
Projects
None yet
Development

No branches or pull requests

2 participants