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 <> 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:

and here:

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:

and it generates this image:

I hope this helps.  Let us know if you have any other questions regarding this.


On Tue, Aug 6, 2013 at 10:09 AM, Reju Sam John <> 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)

L = [11,15,18,20,22,25,30,35,40]

#for i in range (0, 8):
for kk in L:   
    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.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') 
            # i = i+1

for p, cax in zip(pc.plots, colorbars):
    cbar = cb.Colorbar(cax, p.image, orientation='vertical')
    p.colorbar = cbar
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 "", line 24, in <module>
    pc.set_width(3.0, 'mpc') 
  File "/data1/pdf/csurajit/yt-x86_64/src/yt-hg/yt/visualization/", line 292, in set_width
    plot.set_width(width, unit)
  File "/data1/pdf/csurajit/yt-x86_64/src/yt-hg/yt/visualization/", line 458, in set_width
  File "/data1/pdf/csurajit/yt-x86_64/src/yt-hg/yt/visualization/", line 476, in _refresh_display_width
  File "/data1/pdf/csurajit/yt-x86_64/src/yt-hg/yt/visualization/", line 423, in _redraw_image
  File "/data1/pdf/csurajit/yt-x86_64/src/yt-hg/yt/visualization/", line 263, in _run_callbacks
  File "/data1/pdf/csurajit/yt-x86_64/src/yt-hg/yt/visualization/", 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/", 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

Cameron Hummels
Postdoctoral Researcher
Steward Observatory
University of Arizona

yt-users mailing list

Reju Sam John