[yt-users] plotting questions
Matthew Turk
matthewturk at gmail.com
Tue Nov 24 09:05:54 PST 2009
Hi Shankar,
> Also, I am not able to loop over method 1. I am using the stupid way as shown below.
Sure you can loop! :) Here's a way to do it:
for ax in range(3):
p = plots.get_slice("RedshiftOutput0002", "Density", ax)
p.modify["grids"]()
p.modify["contours"]("Density")
p.save_image("something_%s" % ax)
That last line will make sure that your images have different names --
and that's actually what's going wrong with the second loop that you
had below.
(I'd like to note that having similar plots on different axes is why
the Plot Collection is around -- so I'd suggest you stick to that, as
it will make changing widths and whatnot easier.)
> And method 2 is not showing the grids.
> for ax in range(3):
> pc.add_slice("Density", ax).modify["grids"]()
> pc.add_slice("Density", ax).modify["contour"]("Density")
> pc.save("plot2")
Ah! What's going on here is that the plot collection, at the end of
the loop, has *six* plots:
slice on x with grids
slice on x with contours
slice on y with grids
slice on y with contours
slice on z with grids
slice on z with contours
BUT, the callbacks aren't taken into account when creating image file
names. So it just overwirtes the first slice with the second, the
third with the fourth, and the fifth with the sixth. What you
probably want to do is:
for ax in range(3):
p = pc.add_slice("Density", ax)
p.modify["grids"]()
p.modify["contour"]("Density")
pc.save("plot2")
This way you're modifying the same plot object with both grids and contours.
Best of luck,
Matt
More information about the yt-users
mailing list