[yt-users] Problem with multi plot
Cameron Hummels
chummels at gmail.com
Wed Aug 7 05:10:17 PDT 2013
Hi Reju,
There are details on how to do that in the two links that I provided you
from the yt documentation. Read those and poke around the docs to get an
idea of how to do some more advanced functionality.
Cameron
On Wed, Aug 7, 2013 at 2:40 AM, Reju Sam John <rejusamjohn at gmail.com> wrote:
> Dear Cameron Hummels,
>
> Your script to generate a 3x3 image is quite sufficient. But is there any
> attribute to 'AMRSlice' object (or any other method) to produce a color
> code scale on the right of each row or below to each column.
>
>
>
> On Wed, Aug 7, 2013 at 3:15 AM, Cameron Hummels <chummels at gmail.com>wrote:
>
>> Hi Reju,
>>
>> It looks like your for loops are in the wrong order (as you correctly
>> surmised). Your first "for" loop (i.e. for kk in L:) goes through each
>> redshift output, and it generates a new 3x3 plot collection for each one
>> which it populates with the slice plots for that redshift.
>>
>> What I think you want to do is run the two later for loops (i.e. for i
>> in range (0,3): for j in range (0, 3):) first, and then load in the
>> individual redshift outputs to populate the plot collection.
>> Unfortunately, and someone can correct me here if I'm wrong, but I don't
>> think you'll be able to use the Plot Collection data structure to do this.
>> PlotCollections are necessarily tied to a single data output, not several
>> as you're trying to do here with the data outputs for each redshift.
>>
>> What you'll likely have to do instead is just generate an array of
>> slices, where you generate each from a different data output. There is
>> some examples of this on the yt docs page here:
>>
>>
>> http://yt-project.org/doc/cookbook/complex_plots.html#multi-plot-slice-and-projections
>>
>> and here:
>>
>>
>> http://yt-project.org/doc/cookbook/complex_plots.html#advanced-multi-plot-multi-panel
>>
>>
>> In addition, I wrote up a quick basic script to generate a 3x3 image
>> array with slices (or projections) from a bunch of different data outputs.
>> I think it is what you're trying to do. It's here:
>>
>> http://paste.yt-project.org/show/3749/
>>
>> and it generates this image:
>>
>> http://i.imgur.com/lhUrcbI.png
>>
>> I hope this helps. Let us know if you have any other questions regarding
>> this.
>>
>> Cameron
>>
>>
>> On Tue, Aug 6, 2013 at 10:09 AM, Reju Sam John <rejusamjohn at gmail.com>wrote:
>>
>>> Dear all,
>>>
>>> I am trying to create a muti plot of density's at different red-shift
>>> with the following code.
>>>
>>> from yt.mods import *
>>> import matplotlib.colorbar as cb
>>>
>>> fig, axes, colorbars = get_multi_plot( 3, 3, colorbar='vertical', bw = 3)
>>> file1="/app/run/csarkar/surajit/simulation_shock/simulation5/RD00"
>>> file2="/RedshiftOutput00"
>>>
>>> L = [11,15,18,20,22,25,30,35,40]
>>>
>>> #for i in range (0, 8):
>>> for kk in L:
>>> fn_i=str(kk)
>>> fn=file1+fn_i+file2+fn_i
>>> print fn
>>> pf = load(fn)
>>> pc = PlotCollection(pf, center=[0.5, 0.5, 0.5])
>>> for i in range (0,3):
>>> for j in range (0, 3):
>>> p = pc.add_slice("Density", 2, axes = axes[i][j],figure =
>>> fig, use_colorbar=False)
>>> p.set_log_field(True)
>>> p.set_zlim(1e-31,5e-26)
>>> p.set_cmap("jet")
>>> p.modify["contour"]("Density", ncont=10, plot_args =
>>> {'colors':'w'},clim=(2e-28,2e-26))
>>> p.modify["contour"]("Temperature", ncont=10, plot_args =
>>> {'colors':'k'},clim=(3e7,1e8))
>>> #pc.set_width(3.0, 'mpc')
>>> #break
>>> # i = i+1
>>>
>>>
>>> for p, cax in zip(pc.plots, colorbars):
>>> cbar = cb.Colorbar(cax, p.image, orientation='vertical')
>>> p.colorbar = cbar
>>> p._autoset_label()
>>> fig.savefig("multi_plot_3_3" % pf)
>>>
>>>
>>> But I am getting a wrong result. It is printing same figure in all
>>> panels.
>>>
>>> I think my logic(algorithm) is wrong. We have to reverse first two for
>>> loop. But that also making problem. Please help me.
>>>
>>> And also if I include the following line in the code. (in my code I
>>> commented it out)
>>>
>>> pc.set_width(3.0, 'mpc')
>>>
>>> it is showing following error.
>>>
>>> *Traceback (most recent call last):*
>>> * File "multi_plot_loop.py", line 24, in <module>*
>>> * pc.set_width(3.0, 'mpc') *
>>> * File
>>> "/data1/pdf/csurajit/yt-x86_64/src/yt-hg/yt/visualization/plot_collection.py",
>>> line 292, in set_width*
>>> * plot.set_width(width, unit)*
>>> * File
>>> "/data1/pdf/csurajit/yt-x86_64/src/yt-hg/yt/visualization/plot_types.py",
>>> line 458, in set_width*
>>> * self._refresh_display_width()*
>>> * File
>>> "/data1/pdf/csurajit/yt-x86_64/src/yt-hg/yt/visualization/plot_types.py",
>>> line 476, in _refresh_display_width*
>>> * self._redraw_image()*
>>> * File
>>> "/data1/pdf/csurajit/yt-x86_64/src/yt-hg/yt/visualization/plot_types.py",
>>> line 423, in _redraw_image*
>>> * self._run_callbacks()*
>>> * File
>>> "/data1/pdf/csurajit/yt-x86_64/src/yt-hg/yt/visualization/plot_types.py",
>>> line 263, in _run_callbacks*
>>> * cb(self)*
>>> * File
>>> "/data1/pdf/csurajit/yt-x86_64/src/yt-hg/yt/visualization/plot_modifications.py",
>>> line 312, in __call__*
>>> * self.ncont = np.linspace(self.clim[0], self.clim[1], self.ncont)*
>>> * File
>>> "/data1/pdf/csurajit/yt-x86_64/lib/python2.7/site-packages/numpy/core/function_base.py",
>>> line 74, in linspace*
>>> * num = int(num)*
>>> *TypeError: only length-1 arrays can be converted to Python scalars*
>>>
>>>
>>> Please suggest me the most efficient way to achieve my goal (create a
>>> muti plot of density's at different red-shift).
>>>
>>>
>>>
>>>
>>> --
>>> Reju Sam John
>>>
>>> _______________________________________________
>>> yt-users mailing list
>>> yt-users at lists.spacepope.org
>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>>
>>>
>>
>>
>> --
>> Cameron Hummels
>> Postdoctoral Researcher
>> Steward Observatory
>> University of Arizona
>> http://chummels.org
>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>>
>
>
> --
> Reju Sam John
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
--
Cameron Hummels
Postdoctoral Researcher
Steward Observatory
University of Arizona
http://chummels.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20130807/def9c9dd/attachment.html>
More information about the yt-users
mailing list