[yt-users] 2D Slice Plot Data-Reflect or Rotate to make 4 window slice plot

Nathan Goldbaum nathan12343 at gmail.com
Fri Jun 10 08:09:37 PDT 2016


On Fri, Jun 10, 2016 at 9:55 AM, Chris M <christopherm02 at gmail.com> wrote:

> Hello all,
>
> I've been trying to make a 4 window slice plot using 2D data. The method I
> want to use is to redraw itself reflected around an axis so that it creates
> a 4 window slice plot (similar to the ones seen on A Few Complex Plots page
> but each plot should be rotated).
>
>  If I could get some help on this or even just how to reflect one 2D plot
> it would be greatly appreciated.
>

One can control which simulation coordinate axis is set to the x or y axis
of a yt plot by manipulating the ds.coordinates object. See this example:

https://gist.github.com/anonymous/cc879dbab87d21bd233b979774d5ebf0

I'm not sure offhand if this trick could be easily applied to a multi-panel
plot.

There isn't an interface to force rotations or reflections for plots,
although if someone wanted to add that functionality and came up with a
nice clean API for it, I bet it would be accepted into yt. It certainly
comes up as a feature request on the mailing list pretty often.

If you aren't interested in improving yt to add this capability, it may be
easiest to generate these plots outside of yt using your favorite plotting
package. You can get the image buffer associated with a plot via the frb
attribute of yt plot objects and plot it using matplotlib, like so:

    from matplotlib import pyplot as plt
    import numpy as np
    import yt

    ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')

    slc = yt.SlicePlot(ds, 2, 'density')

    # density_image is an 800x800 ImageArray instance
    density_image = slc.frb['density']

    # density_image is a 2D numpy array
    density_image = np.array(density_image)

    plt.imshow(density_image)

The "frb" attribute points to the FixedResolutionBuffer instance associated
with that plot object. See:

http://yt-project.org/docs/dev/analyzing/generating_processed_data.html#d-image-arrays
http://yt-project.org/docs/dev/reference/api/generated/yt.visualization.fixed_resolution.FixedResolutionBuffer.html

-Nathan


> Regards,
> Chris
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20160610/d1ae6bf6/attachment.html>


More information about the yt-users mailing list