Plot collections on non-square slices
Hi YT Users, I have a computational domain that is not cubical, and I want to plot a slice through it that is rectangular rather than square. I can make a slice with PlotCollection, but when I write the image to a file using save, I find that it has been padded with whitesapce on the left and right to make it square. I would like the image to have the same aspect ratio as the data, not be white-padded. Is there a way to do this with PlotCollection, or should I just give up and use FixedResolutionBuffer to extract the data and construct the image myself? Thanks. -- Mark Krumholz krumholz@ucolick.org
Hi Mark, You can manually specify the size of the figure that will be created by setting the fig_size keyword. For example: pf = load(fn) pc = PlotCollection(pf) fig_size = [4, 3] # the figure size in inches pc.add_slice('Density',0,fig_size = fig_size) pc.save() # saves a slice of Density that is 4 x 3 inches. Hope that was helpful. -Nathan On Jul 24, 2012, at 3:55 PM, Mark Krumholz wrote:
Hi YT Users,
I have a computational domain that is not cubical, and I want to plot a slice through it that is rectangular rather than square. I can make a slice with PlotCollection, but when I write the image to a file using save, I find that it has been padded with whitesapce on the left and right to make it square. I would like the image to have the same aspect ratio as the data, not be white-padded. Is there a way to do this with PlotCollection, or should I just give up and use FixedResolutionBuffer to extract the data and construct the image myself?
Thanks.
-- Mark Krumholz krumholz@ucolick.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
On Jul 24, 2012, at 4:29 PM, Nathan Goldbaum wrote:
Hi Mark,
You can manually specify the size of the figure that will be created by setting the fig_size keyword. For example:
pf = load(fn)
pc = PlotCollection(pf)
fig_size = [4, 3] # the figure size in inches
pc.add_slice('Density',0,fig_size = fig_size)
pc.save() # saves a slice of Density that is 4 x 3 inches.
Hope that was helpful.
-Nathan
I just tried it, and I'm afraid this doesn't work. Setting the figure size to, say [1,4] (the aspect ratio of my figure) just results in a squashed version of what I got before. The whitespace is still there, and the image of the data is now artificially compressed. -- Mark Krumholz krumholz@ucolick.org
Hi Mark, I've been running non-cubic simulation domains and I've run into this same issue in the past. Unfortunately, there isn't a simple way around it (at least not that I've found at the moment). Using an FRB is an option, or alternatively, you could play with this script that I've use for some stuff in the past: http://paste.yt-project.org/show/2570/ The script still makes use of some of the capabilities of PlotCollection, but ultimately ends up producing and saving the image using pylab. Right now there is something goofy when you slice perpendicular to the long axis of a non-cubic domain -- the script used to work for all axes, but I think something changed in yt along the way. I'll let you know if I come across the solution to that. I think it might require a certain pc.set_width call. Let me know if you have any question about the script, hopefully it's functionality is pretty straight forward. -Devin On Tue, Jul 24, 2012 at 5:33 PM, Mark Krumholz <krumholz@ucolick.org> wrote:
On Jul 24, 2012, at 4:29 PM, Nathan Goldbaum wrote:
Hi Mark,
You can manually specify the size of the figure that will be created by setting the fig_size keyword. For example:
pf = load(fn)
pc = PlotCollection(pf)
fig_size = [4, 3] # the figure size in inches
pc.add_slice('Density',0,fig_size = fig_size)
pc.save() # saves a slice of Density that is 4 x 3 inches.
Hope that was helpful.
-Nathan
I just tried it, and I'm afraid this doesn't work. Setting the figure size to, say [1,4] (the aspect ratio of my figure) just results in a squashed version of what I got before. The whitespace is still there, and the image of the data is now artificially compressed.
-- Mark Krumholz krumholz@ucolick.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
-- "I'm here to fight for truth, and justice, and the American way."
participants (3)
-
Devin Silvia
-
Mark Krumholz
-
Nathan Goldbaum