Seite 1 von 1

white space um plot entfernen

Verfasst: Donnerstag 7. August 2014, 11:35
von unterzwerg
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

Re: white space um plot entfernen

Verfasst: Donnerstag 7. August 2014, 12:42
von MagBen
Probier das mal

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")
plot2.png sollte weniger whitespace haben als plot1.png.