Hi yt-users! So I have a question about set_buff_size. I would like my pixels to be the same size as my more refined cell in a projectionplot, so have a couple lines of code like this: plot6z=yt.ProjectionPlot(ds,"x","density",center=[0.5,0.5,0.33],width=(76,'kpc')) plot6z.set_buff_size(2000) plot6z.save('JO201scc_76kpc_'+loop[i]+'t'+times[i]) When I take a look at the png file that is made, there are 800 pixels across instead of the 2000 that I expect. I just checked the docs here: http://yt-project.org/doc/visualizing/plots.html and based on the SlicePlot example I feel like it should work! Then again, it looks like in the example the number of pixels also doesn't change? I would appreciate any/all advice! Thanks!! Stephanie -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY stonnes@gmail.com
Hi Stephanie, When you call plot.save(), you need to pass something like this: plot6z.save('JO201scc_76kpc_'+loop[i]+'t'+times[i], mpl_kwargs={'dpi': 300}) Or whichever dpi you'd like to use. In addition, you probably also want to call plot.set_figure_size(), which accepts a size in inches for the matplotlib figure used for the plot. The actual number of pixels in the resulting png image saved by matplotlib is dpi*figure_size. Also if you *really* want this to be exact, you probably should disable the colorbar and the axes, so that the resulting figure contains *just* the image. On Wed, Aug 29, 2018 at 4:08 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Hi yt-users!
So I have a question about set_buff_size. I would like my pixels to be the same size as my more refined cell in a projectionplot, so have a couple lines of code like this:
plot6z=yt.ProjectionPlot(ds,"x","density",center=[0.5,0.5,0.33],width=(76,'kpc')) plot6z.set_buff_size(2000) plot6z.save('JO201scc_76kpc_'+loop[i]+'t'+times[i])
When I take a look at the png file that is made, there are 800 pixels across instead of the 2000 that I expect. I just checked the docs here: http://yt-project.org/doc/visualizing/plots.html
and based on the SlicePlot example I feel like it should work! Then again, it looks like in the example the number of pixels also doesn't change?
I would appreciate any/all advice!
Thanks!!
Stephanie
-- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Cool, thanks! I suspected that it was just not saving the buffer size I wanted. So my quick follow-up question: is set_buff_size useless then? Thanks, Stephanie -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY stonnes@gmail.com On Wed, Aug 29, 2018 at 4:16 PM Nathan Goldbaum <nathan12343@gmail.com> wrote:
Hi Stephanie,
When you call plot.save(), you need to pass something like this:
plot6z.save('JO201scc_76kpc_'+loop[i]+'t'+times[i], mpl_kwargs={'dpi': 300})
Or whichever dpi you'd like to use. In addition, you probably also want to call plot.set_figure_size(), which accepts a size in inches for the matplotlib figure used for the plot. The actual number of pixels in the resulting png image saved by matplotlib is dpi*figure_size.
Also if you *really* want this to be exact, you probably should disable the colorbar and the axes, so that the resulting figure contains *just* the image.
On Wed, Aug 29, 2018 at 4:08 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Hi yt-users!
So I have a question about set_buff_size. I would like my pixels to be the same size as my more refined cell in a projectionplot, so have a couple lines of code like this:
plot6z=yt.ProjectionPlot(ds,"x","density",center=[0.5,0.5,0.33],width=(76,'kpc')) plot6z.set_buff_size(2000) plot6z.save('JO201scc_76kpc_'+loop[i]+'t'+times[i])
When I take a look at the png file that is made, there are 800 pixels across instead of the 2000 that I expect. I just checked the docs here: http://yt-project.org/doc/visualizing/plots.html
and based on the SlicePlot example I feel like it should work! Then again, it looks like in the example the number of pixels also doesn't change?
I would appreciate any/all advice!
Thanks!!
Stephanie
-- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
No, you need to use it along with a custom dpi and a custom figure size in inches to get the exact resplution you want. It controls the resolution of the image buffer yt passes to matplotlib. If you don’t want to deal with matplotlib at all, you could get an image via the frb attribute of the plot object you’re working with, you’ll get an image with the resolution you specify with set_buff_size. Something like this: plot.set_buff_size(1600) image = plot.frb[“gas”, “density”] image will be a 1600x1600 2D ndarray containing an image of the density field. On Wed, Aug 29, 2018 at 8:51 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Cool, thanks! I suspected that it was just not saving the buffer size I wanted. So my quick follow-up question: is set_buff_size useless then?
Thanks, Stephanie
-- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com
On Wed, Aug 29, 2018 at 4:16 PM Nathan Goldbaum <nathan12343@gmail.com> wrote:
Hi Stephanie,
When you call plot.save(), you need to pass something like this:
plot6z.save('JO201scc_76kpc_'+loop[i]+'t'+times[i], mpl_kwargs={'dpi': 300})
Or whichever dpi you'd like to use. In addition, you probably also want to call plot.set_figure_size(), which accepts a size in inches for the matplotlib figure used for the plot. The actual number of pixels in the resulting png image saved by matplotlib is dpi*figure_size.
Also if you *really* want this to be exact, you probably should disable the colorbar and the axes, so that the resulting figure contains *just* the image.
On Wed, Aug 29, 2018 at 4:08 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Hi yt-users!
So I have a question about set_buff_size. I would like my pixels to be the same size as my more refined cell in a projectionplot, so have a couple lines of code like this:
plot6z=yt.ProjectionPlot(ds,"x","density",center=[0.5,0.5,0.33],width=(76,'kpc')) plot6z.set_buff_size(2000) plot6z.save('JO201scc_76kpc_'+loop[i]+'t'+times[i])
When I take a look at the png file that is made, there are 800 pixels across instead of the 2000 that I expect. I just checked the docs here: http://yt-project.org/doc/visualizing/plots.html
and based on the SlicePlot example I feel like it should work! Then again, it looks like in the example the number of pixels also doesn't change?
I would appreciate any/all advice!
Thanks!!
Stephanie
-- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
Okay! Thanks for the explanation and other idea. Best, Stephanie -- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY stonnes@gmail.com On Wed, Aug 29, 2018 at 10:16 PM Nathan Goldbaum <nathan12343@gmail.com> wrote:
No, you need to use it along with a custom dpi and a custom figure size in inches to get the exact resplution you want. It controls the resolution of the image buffer yt passes to matplotlib.
If you don’t want to deal with matplotlib at all, you could get an image via the frb attribute of the plot object you’re working with, you’ll get an image with the resolution you specify with set_buff_size. Something like this:
plot.set_buff_size(1600) image = plot.frb[“gas”, “density”]
image will be a 1600x1600 2D ndarray containing an image of the density field.
On Wed, Aug 29, 2018 at 8:51 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Cool, thanks! I suspected that it was just not saving the buffer size I wanted. So my quick follow-up question: is set_buff_size useless then?
Thanks, Stephanie
-- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com
On Wed, Aug 29, 2018 at 4:16 PM Nathan Goldbaum <nathan12343@gmail.com> wrote:
Hi Stephanie,
When you call plot.save(), you need to pass something like this:
plot6z.save('JO201scc_76kpc_'+loop[i]+'t'+times[i], mpl_kwargs={'dpi': 300})
Or whichever dpi you'd like to use. In addition, you probably also want to call plot.set_figure_size(), which accepts a size in inches for the matplotlib figure used for the plot. The actual number of pixels in the resulting png image saved by matplotlib is dpi*figure_size.
Also if you *really* want this to be exact, you probably should disable the colorbar and the axes, so that the resulting figure contains *just* the image.
On Wed, Aug 29, 2018 at 4:08 PM Stephanie Tonnesen <stonnes@gmail.com> wrote:
Hi yt-users!
So I have a question about set_buff_size. I would like my pixels to be the same size as my more refined cell in a projectionplot, so have a couple lines of code like this:
plot6z=yt.ProjectionPlot(ds,"x","density",center=[0.5,0.5,0.33],width=(76,'kpc')) plot6z.set_buff_size(2000) plot6z.save('JO201scc_76kpc_'+loop[i]+'t'+times[i])
When I take a look at the png file that is made, there are 800 pixels across instead of the 2000 that I expect. I just checked the docs here: http://yt-project.org/doc/visualizing/plots.html
and based on the SlicePlot example I feel like it should work! Then again, it looks like in the example the number of pixels also doesn't change?
I would appreciate any/all advice!
Thanks!!
Stephanie
-- Dr. Stephanie Tonnesen Associate Research Scientist CCA, Flatiron Institute New York, NY
stonnes@gmail.com _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
_______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org
participants (2)
-
Nathan Goldbaum
-
Stephanie Tonnesen