Frage

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!

War es hilfreich?

Lösung

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()

Plot

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).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top