Flip one axis in multiaxis plot

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

Flip one axis in multiaxis plot

Tiago Pereira
Howdy,

Does anyone know how to flip the axis of a plot made with
create_line_plot()? So that the index (x) axis goes from a larger number
to a smaller number.

If using Plot().plot, this can be achieved with orientation='bottom
right' for example. The issue here is that I have an existing plot that
has x increasing from left to right, and I want to overplot another line
plot with x decreasing from left to right. Looking in the example
multiaxis_using_Plot.py, I see that the way to add a second plot is to
use create_line_plot() and then add that to the Plot instance. But it
always seems to use the same x order as in the original plot. There
doesn't seem to be an orientation keyword for create_line_plot.

Any ideas on how to add two plots with different axis, one with the
index increasing and the other with the index decreasing?

Thanks,

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

Re: Flip one axis in multiaxis plot

Tiago Pereira
Hi,

Answering my own question, here's a method that will work. It doesn't
use create_line_plot, but rather several Plot() calls that are put in an
OverlayPlotContainer.

Here's a simplified code:

# first plot (normal x order)
plotdata1 = ArrayPlot(x1=x1, y1=y1)
plot1 = Plot(plotdata1)
plot1.plot('x1', 'y1')

# second plot (reverse x order by using bottom right orientation)
plotdata2 = ArrayPlot(x2=x2, y2=y2)
plot2 = Plot(plotdata2)
plot2.plot('x2', 'y2')
plot2.default_origin = 'bottom right'
plot2.x_axis.orientation = 'top'

# put both in container
my_container = OverlayPlotContainer()
my_container.add(plot1)
my_container.add(plot2)

# display
traits_view = View(Group(Item('my_container',
                              editor=ComponentEditor())))


Cheers,

Tiago




On 25/7/12 11:53 AM, Tiago Pereira wrote:

> Howdy,
>
> Does anyone know how to flip the axis of a plot made with
> create_line_plot()? So that the index (x) axis goes from a larger number
> to a smaller number.
>
> If using Plot().plot, this can be achieved with orientation='bottom
> right' for example. The issue here is that I have an existing plot that
> has x increasing from left to right, and I want to overplot another line
> plot with x decreasing from left to right. Looking in the example
> multiaxis_using_Plot.py, I see that the way to add a second plot is to
> use create_line_plot() and then add that to the Plot instance. But it
> always seems to use the same x order as in the original plot. There
> doesn't seem to be an orientation keyword for create_line_plot.
>
> Any ideas on how to add two plots with different axis, one with the
> index increasing and the other with the index decreasing?
>
> Thanks,
>
> Tiago

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