Indenting within a section

I am working on my matplotlibwidget, which I created using QtDesigner.

When I draw my control points in my plot, they are mostly located on the border or cross axes. Which is not very familiar to me.

So my question is: how can I say matplotlib to add some kind of β€œinner padding” between the borders of the graph and the test points. So, for example, if my minimum value is "500", I would like to build a left border of about 400, so there is some margin between the smallest point and the border.

Thank you in advance!

+6
source share
1 answer

plt.margins can be used to set up automatic completion of your data, as shown below.

 import matplotlib.pyplot as plt import numpy as np x = np.arange(10) y = np.power(x, 3) plt.plot(x, y, 'ro') # Create a 5% (0.05) and 10% (0.1) padding in the # x and y directions respectively. plt.margins(0.05, 0.1) plt.show() 

Plot

If you had a minimum value of 500 and wanted the border to be around 400 , then you can choose the x-margin percentage from 0.2 , as in plt.margins(0.2, 0.2) .

+12
source

All Articles