I'm working on my matplotlibwidget that I've created with QtDesigner.
When i draw my testpoints into my plot, they are mostly arranged at the border or cross the axes. Which does not look very familiar to me.
So my question is, how can i tell matplotlib to add some kind of "inner padding" between plot-border and test points. So for example if my minimum value is "500" i would like to plot the left border at around 400, so there is some margin between the least point and border.
Thank you in advance!
Padding is the empty space between the axis (ticks and labels) and the edge of the figure.
Padding (height/width) between edges of adjacent subplots, as a fraction of the font size. Defaults to pad. rect : tuple (left, bottom, right, top), optional. A rectangle (left, bottom, right, top) in the normalized figure coordinate that the whole subplots area (including labels) will fit into. Default is (0, 0, 1, 1) ...
Using subplots_adjust() method to set the spacing between subplots. We can use the plt. subplots_adjust() method to change the space between Matplotlib subplots.
plt.margins
can be used to adjust the automatic padding around your data as 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()
If you had a minimum value of 500
and wanted the border to be around 400
then you could choose an x-margin percentage of 0.2
as in plt.margins(0.2, 0.2)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With