Hi Greta,

The development version of yt has a function called toggle_right_handed that might be useful here.

Take a look at the following example: https://gist.github.com/2937442f997bb16f5505fa470edb2480

Unfortunately you need to be using the development version to do this, there's no workaround for the version you're using, since the call to `invert_xaxis` needs to happen while the plot is getting set up. There are instructions on how to build yt from source here:

Alternatively if you're using conda you can use the nightly conda builds:

Nathan

On Tue, Apr 11, 2017 at 12:00 AM, Greta Zhong wrote:
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

_______________________________________________
yt-users mailing list
yt-users@lists.spacepope.org
http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org