Non matching time based data

7 views
Skip to first unread message

Jon

unread,
Dec 12, 2009, 7:22:11 AM12/12/09
to pycha
I'm not sure if this is possible, but I'd like to show two data lines
in a line chart. The x axis is the date that each y value occurred. My
problem is that the two data lines do not have matching x value dates.
How can I show both of these on the same line chart? The idea is that
the user can compare two different data sets. From what I understand
in pycha, I have to define myself the x-axis labels, so would probably
have to calculate myself, based on the data, which x-axis point gets
which label. Is there a better way?

Lorenzo Gil Sanchez

unread,
Dec 13, 2009, 12:28:59 PM12/13/09
to py...@googlegroups.com
2009/12/12 Jon <juan....@gmail.com>:
> I'm not sure if this is possible, but I'd like to show two data lines
> in a line chart. The x axis is the date that each y value occurred. My
> problem is that the two data lines do not have matching x value dates.
> How can I show both of these on the same line chart?

I think you can use a LineChart with two datasets. If I remember
correctly the datasets do not necessarely need to have the same amount
of points or even have the same x values for the points.
Actually, I haven't need your use case even before so I might be wrong.

The idea is that
> the user can compare two different data sets. From what I understand
> in pycha, I have to define myself the x-axis labels, so would probably
> have to calculate myself, based on the data, which x-axis point gets
> which label. Is there a better way?

There are several ways to tell pycha how to draw the x-axis labels. It
can calculate them based on the datasets, you can give it a range, a
number or ticks or, as you mention, give the full information
manually.

Best regards,

Lorenzo

Jon Black

unread,
Dec 13, 2009, 3:10:29 PM12/13/09
to py...@googlegroups.com


2009/12/13 Lorenzo Gil Sanchez <lorenzo.g...@gmail.com>

2009/12/12 Jon <juan....@gmail.com>:
> I'm not sure if this is possible, but I'd like to show two data lines
> in a line chart. The x axis is the date that each y value occurred. My
> problem is that the two data lines do not have matching x value dates.
> How can I show both of these on the same line chart?

I think you can use a LineChart with two datasets. If I remember
correctly the datasets do not necessarely need to have the same amount
of points or even have the same x values for the points.
Actually, I haven't need your use case even before so I might be wrong.

I will give it a go to see if it works.
 

 The idea is that
> the user can compare two different data sets. From what I understand
> in pycha, I have to define myself the x-axis labels, so would probably
> have to calculate myself, based on the data, which x-axis point gets
> which label. Is there a better way?

There are several ways to tell pycha how to draw the x-axis labels. It
can calculate them based on the datasets, you can give it a range, a
number or ticks or, as you mention, give the full information
manually.

If I try to add a date type to the dataset, I get a type error, so I don't think it will determine the range of the x-axis for date types. Instead I have to pass in integers and then change the x-axis labels myself. It would be nice to be able to set the dataset using dates:

date = datetime.date(2009, 1, 1)
data_point = (date, 10.0)

Assuming that there are two datasets that both use dates for the x-axis, it would be nice for the chart to then determine the range of dates and plot the values in the dataset in the correct place....at least, this is what I'm aiming for :)
 

Best regards,

Lorenzo

--

You received this message because you are subscribed to the Google Groups "pycha" group.
To post to this group, send email to py...@googlegroups.com.
To unsubscribe from this group, send email to pycha+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pycha?hl=en.



Jon Black

unread,
Dec 19, 2009, 5:07:00 AM12/19/09
to py...@googlegroups.com
You're right, it will plot multiple data sets even if they have a different number of points. I'm not sure yet if I can easily make it plot related data sets correctly, putting points with the same x axis value in the correct place.

At the moment, I'm having trouble with the auto generation of the x axis range. My x axis values do not start from 0, but it seems pychart always does. The attached image (screenshot.png) was generated with the following data set:

(u'dset1', [(10, 15.800000000000001), (11, 17.899999999999999), (12, 25.800000000000001), (13, 27.899999999999999), (14, 12.0), (15, 6.0), (16, 3.0)])

As you can see, the x values range from 10 to 16.

Compare this to the second image (screenshot2.png) which was generated from the same data set, except the values begin from 0:

(u'dset1', [(0, 15.800000000000001), (1, 17.899999999999999), (2, 25.800000000000001), (3, 27.899999999999999), (4, 12.0), (5, 6.0), (6, 3.0)])

I'm aware that you can set the range of the x-axis, but I wanted to know if I'm doing something wrong to make the auto generation fail, or that this is in fact a bug?

Thanks,
Jon

2009/12/13 Jon Black <juan....@gmail.com>
Screenshot.png
Screenshot2.png

Lorenzo Gil Sanchez

unread,
Mar 27, 2010, 4:32:49 AM3/27/10
to py...@googlegroups.com
First of all, sorry for the super late reply :-(

2009/12/19 Jon Black <juan....@gmail.com>:


> You're right, it will plot multiple data sets even if they have a different
> number of points. I'm not sure yet if I can easily make it plot related data
> sets correctly, putting points with the same x axis value in the correct
> place.
>
> At the moment, I'm having trouble with the auto generation of the x axis
> range. My x axis values do not start from 0, but it seems pychart always
> does. The attached image (screenshot.png) was generated with the following
> data set:
>
> (u'dset1', [(10, 15.800000000000001), (11, 17.899999999999999), (12,
> 25.800000000000001), (13, 27.899999999999999), (14, 12.0), (15, 6.0), (16,
> 3.0)])
>
> As you can see, the x values range from 10 to 16.
>
> Compare this to the second image (screenshot2.png) which was generated from
> the same data set, except the values begin from 0:
>
> (u'dset1', [(0, 15.800000000000001), (1, 17.899999999999999), (2,
> 25.800000000000001), (3, 27.899999999999999), (4, 12.0), (5, 6.0), (6,
> 3.0)])
>

In Pycha the x axis always starts at 0. You can change the tick labels
to print whatever you like but at the moment we suppose both axis do
have a origin at 0.

Adding support for axis origin at other value different than 0 would
not be very hard to do so I'm open for patches to add this.

Best regards,

Lorenzo

Reply all
Reply to author
Forward
0 new messages