Ich erzeuge Plots und speichere sie in PDF-Format. Dabei möchte ich den weißen Rand nicht mit abspeichern.
Ich benutze dazu savefig(...,bbox_inches='tight')
Da funktioniert aber nicht immer, obwohl es im Tutorial für diesen Fall empfohlen wird.
MatplotlibVersion = 1.3.1
white space um plot entfernen
Probier das malplot2.png sollte weniger whitespace haben als plot1.png.
Code: Alles auswählen
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-3,3,1000)
plt.figure()
plt.plot(x, x**2)
plt.savefig("plot1.png")
plt.figure()
plt.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95)
plt.plot(x, x**2)
plt.savefig("plot2.png")