How to scale a shape to a specific size in inches in matplotlib

Suppose I am preparing a PDF digit in matplotlib, and, say, I indicated that the original shape dimensions are 10x10 inches. Is it possible to create essentially the same shape, but reduced to 7x7in (so that all fonts / sizes of dots, etc. are reduced accordingly)?

I understand that I can open my 10x10 file in a vector graphics editor and rescale, but I was wondering if there is some simple switch that will do this directly from matplotlib.

+4
source share
1 answer

Use set_size_inches , for example:

 import matplotlib.pyplot as plt fig=plt.figure() ax=fig.add_subplot(111) fig.set_size_inches([10,10]) ax.plot([1,3,2],[2,2,2],'ro-') plt.savefig('10x10.png') fig.set_size_inches([4,4]) plt.savefig('4x4.png') 
+2
source

Source: https://habr.com/ru/post/1415613/


All Articles