I use python(3.6)+numpy+matplotlib(2.0) (Anaconda distribution under
Win7) to draw simple figures and I meet the following problem. All the
figures that I plot come out the same size (432x288 px). This is OK for
simple curves but leads to obscure plots in more complicated cases.
I notice that all figures in the pyplot tutorial have size 550x450 as
they do also in the Matplotlib examples, while many figures in the
gallery are 165x135.
How canI force the size of a picture in order to display it full screen
or to cover most of anA4 sheet of paper ?
Thank you for your help
JP Grivet
···
---
L'absence de virus dans ce courrier ?lectronique a ?t? v?rifi?e par le logiciel antivirus Avast. https://www.avast.com/antivirus
you can use the `figsize` keyword argument when creating a figure to set
its size in inches (1 in = 2.54 cm). You can also set the DPI value
directly with the `dpi` argument. Or you can wait until saving the
figure: the keyword argument is the same.
For example
import matplotlib.pyplot as plt
# Set the dimensions that you want in inches,
# here let's say a quarter of a A4 sheet.
a4_sheet = (21.0, 29.7) # in cm
my_size = [0.5*val/2.54 for val in a4_sheet] # converted in inches
fig, ax = plt.subplots(figsize=my_size) # one could add 'dpi=300'
ax.plot([0, 1, 2], [1, 2, 0]) # dummy plot
# Saving with a specific dot-per-inch (dpi) value, here 300
# Given my_size, the final picture should be ~ 1240x1754
fig.savefig('my_figure_in_300_dpi.png', dpi=300)
You may find more details in the online documentation:
PS: the figure size that you report is a bit surprising. The 2.0
defaults are expected to produce 640?480 pixel-pictures (if I am not wrong).
On 08/03/2017 15:19, Jean-Philippe Grivet wrote:
Hello,
I use python(3.6)+numpy+matplotlib(2.0) (Anaconda distribution under
Win7) to draw simple figures and I meet the following problem. All the
figures that I plot come out the same size (432x288 px). This is OK for
simple curves but leads to obscure plots in more complicated cases.
I notice that all figures in the pyplot tutorial have size 550x450 as
they do also in the Matplotlib examples, while many figures in the
gallery are 165x135.
How canI force the size of a picture in order to display it full screen
or to cover most of anA4 sheet of paper ?
The figures in the gallery and documentation might also be automatically
cropped to eliminate white space.
···
On Wed, Mar 8, 2017 at 10:15 AM, vincent.adrien at gmail.com < vincent.adrien at gmail.com> wrote:
Hello Jean-Philippe,
you can use the `figsize` keyword argument when creating a figure to set
its size in inches (1 in = 2.54 cm). You can also set the DPI value
directly with the `dpi` argument. Or you can wait until saving the
figure: the keyword argument is the same.
For example
import matplotlib.pyplot as plt
# Set the dimensions that you want in inches,
# here let's say a quarter of a A4 sheet.
a4_sheet = (21.0, 29.7) # in cm
my_size = [0.5*val/2.54 for val in a4_sheet] # converted in inches
fig, ax = plt.subplots(figsize=my_size) # one could add 'dpi=300'
ax.plot([0, 1, 2], [1, 2, 0]) # dummy plot
# Saving with a specific dot-per-inch (dpi) value, here 300
# Given my_size, the final picture should be ~ 1240x1754
fig.savefig('my_figure_in_300_dpi.png', dpi=300)
PS: the figure size that you report is a bit surprising. The 2.0
defaults are expected to produce 640?480 pixel-pictures (if I am not
wrong).
On 08/03/2017 15:19, Jean-Philippe Grivet wrote:
> Hello,
>
> I use python(3.6)+numpy+matplotlib(2.0) (Anaconda distribution under
> Win7) to draw simple figures and I meet the following problem. All the
> figures that I plot come out the same size (432x288 px). This is OK for
> simple curves but leads to obscure plots in more complicated cases.
> I notice that all figures in the pyplot tutorial have size 550x450 as
> they do also in the Matplotlib examples, while many figures in the
> gallery are 165x135.
>
> How canI force the size of a picture in order to display it full screen
> or to cover most of anA4 sheet of paper ?
>
> Thank you for your help
> JP Grivet
>
>
> ---
> L'absence de virus dans ce courrier ?lectronique a ?t? v?rifi?e par le
> logiciel antivirus Avast.
> Download Free Antivirus Software | Avast 2024 PC Protection
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> Matplotlib-users Info Page
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org Matplotlib-users Info Page