Datetime on the X-Axis

20 views
Skip to first unread message

Luke Watson

unread,
May 27, 2010, 2:29:53 PM5/27/10
to pycha
Right, great library, it's a big time saver.

What I need is simple: How do I plot a value onto the chart, but have
a different value displayed on the Axis?

Right now I have a chart that plots the value of a variable over a
time period (which is a couple of days). However, I couldn't use
datetime objects as my dataset, so I used seconds since the first
point in time. This works fine, but the person I'm coding the program
for needs the X-Axis to display the date and time of that point,
rather than the seconds since the first point.

Thanks,

Luke

Lorenzo Gil Sanchez

unread,
May 27, 2010, 4:54:55 PM5/27/10
to py...@googlegroups.com
2010/5/27 Luke Watson <hypo...@gmail.com>:

> Right, great library, it's a big time saver.
>
> What I need is simple: How do I plot a value onto the chart, but have
> a different value displayed on the Axis?

You can use the axis.x.ticks option which accesp a list of pairs of this form:

[(0, "tick 1 label"), (1, "tick 2 label"), (2, "tick 3 label")]

so you can compute this list from your dates and set it as the value
of the above option.

In the examples directory there are several examples of this. For
example, check the barchart.py code in that directory.

Best regards,

Lorenzo

Reply all
Reply to author
Forward
0 new messages