[yt-users] Inverting Plot Axes

Greta Zhong gretazhong at yahoo.com
Mon Apr 10 22:00:57 PDT 2017


Hi everyone!

I’m trying to invert the horizontal axis on some simple projection plots. I’m trying to get a projection along the x axis, with y as the vertical and z as the horizontal axis where the horizontal/z axis is inverted, with the horizontal/z axis decreasing from left to right. Here’s the relevant code:

ds.coordinates.x_axis[0] = 2
ds.coordinates.x_axis['x'] = 2
ds.coordinates.y_axis[0] = 1
ds.coordinates.y_axis['x'] = 1

This is just assigning the z axis (2) to the horizontal axis and the y axis (1) to the vertical axis.

plot1 = yt.ProjectionPlot(ds,"x","velocity_x",weight_field='density')
#plot1.plots["velocity_x"].axes.invert_xaxis()
plot1.save()

plot12 = yt.ProjectionPlot(ds,"x","density")
#plot12.plots["density"].axes.invert_xaxis()
plot12.save()

And then I just use ProjectionPlot to make the plots. As you can see, I commented out a sort of matplotlib-y attempt to invert the horizontal axis, to no effect.

I’ve attached two files: the first is what I’m getting with the above code (‘Projection_x_density_actual'), and the second illustrates the orientation I’d like (‘Projection_x_density_rotated'). Unfortunately, I got to the desired orientation by swapping my vertical/horizontal axes like this:

ds.coordinates.x_axis[0] = 1
ds.coordinates.x_axis['x'] = 1
ds.coordinates.y_axis[0] = 2
ds.coordinates.y_axis['x'] = 2

and then just rotating the png in preview.

I can’t find anything in the documentation about this besides the fact that we can use matplotlib objects to customize plots. I’d really appreciate any help on this!

Thanks,
Greta

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20170410/9c9f76c4/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Projection_x_density_actual.png
Type: image/png
Size: 165612 bytes
Desc: not available
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20170410/9c9f76c4/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Projection_x_density_rotated.png
Type: image/png
Size: 210318 bytes
Desc: not available
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20170410/9c9f76c4/attachment-0003.png>


More information about the yt-users mailing list