Multiple axis.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple axis.

Jordan Ilott
I have a strange application where I need to plot two axis for the same data. I understand that this should be possible using multiple axis instances, but there's a twist. One of my axis is a plain, linear axis. The other is non-linear. The primary index axis will be the observation number, the secondary axis will be derived from the time-stamp of each observation. The sample rate is not constant and so there is not a simple mapping of observation to time-stamp. I could imagine some kind of custom axis object that performs a local interpolation to establish the best alignment of date-time to sample number, but I'm not exactly sure where to begin.

Has anyone every done anything like this before or does anyone have any suggestions for me?

Jordan

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Multiple axis.

Jordan Ilott
I thought I follow up with my solution to this challenge, in case someone else needed something similar.

My approach was to create a new mapper that uses the datasource of the primary axis mapper along with it's own datasource, in this case representing the timestamps. The primary axis mapper is also used in the solution.

The map_screen method of my newly created mapper simply performs a local interpolation to map the data into the primary axis data space. Once that's done, the method calls map_screen on the primary axis mapper to accomplish the mapping to screen space.

A reverse mapping is required to handle the mapping of data from screen space to data space and there are a few corner cases, such as what to do when a time to be mapped is earlier or later than any time stamp in the primary data set. A few sensible assumptions for dealing with these extrapolated cases sorted things out for me but the correct choice is probably application dependent.

Once the reverse mapping was implemented, it was easy to listen for updates to the primary axis mapper's range1d and reset the range of the slave mapper, so zooming and panning works fine. Now, thanks to the CalendarScaleSystem, I can zoom in to minute detail or zoom out to a decade tick level.

Jordan


On Mon, Aug 12, 2013 at 2:05 PM, Jordan Ilott <[hidden email]> wrote:
I have a strange application where I need to plot two axis for the same data. I understand that this should be possible using multiple axis instances, but there's a twist. One of my axis is a plain, linear axis. The other is non-linear. The primary index axis will be the observation number, the secondary axis will be derived from the time-stamp of each observation. The sample rate is not constant and so there is not a simple mapping of observation to time-stamp. I could imagine some kind of custom axis object that performs a local interpolation to establish the best alignment of date-time to sample number, but I'm not exactly sure where to begin.

Has anyone every done anything like this before or does anyone have any suggestions for me?

Jordan


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev