Skip to content

xticks on figure #23

@kufton

Description

@kufton

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features, or improvements to existing features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions