0

When saving an image to matplotlib, the aspect ratio is always 4 by 3. Is it possible to change this in any way?

Commands like

plt.gca().set_aspect('equal')

change the aspect ratio only for the object being drawn, but not for the image.

Is it also possible to fit graphs into the selected area (that is, so that the graph occupies the entire area of the sheet, without leaving unnecessary huge fields).

Alexey Ismagilov
  • 187
  • 2
  • 11

1 Answers1

0

Setting the image size for output, just ensure width/height gives the desired aspect ratio and choose a value that will give you the desired zoom (in 8/6 the details will look smaller than 4/3 for a fixed display size):

plt.gcf().set_size_inches(width, height)

Ensuring the plot fills the space:

plt.tight_layout()
mozway
  • 194,879
  • 13
  • 39
  • 75