Matplotlib savefig does not save axes

Defining fig = plt.figure(figsize=(15,10)) at the beginning, saving the file as .jpg and setting bbox_inches=”tight” – plt.savefig(‘filename.jpg’,bbox_inches=”tight”, dpi=150) solved the issue for me. bbox_inches=”tight” seems to fix cropping issues but it didn’t work for .png.

savefig without frames, axes, only content

EDIT Changed aspect=”normal to aspect=”auto’ since that changed in more recent versions of matplotlib (thanks to @Luke19). Assuming : import matplotlib.pyplot as plt To make a figure without the frame : fig = plt.figure(frameon=False) fig.set_size_inches(w,h) To make the content fill the whole figure ax = plt.Axes(fig, [0., 0., 1., 1.]) ax.set_axis_off() fig.add_axes(ax) Then draw your … Read more

Matplotlib savefig image trim

I am continually amazed at how many ways there are to do the same thing in matplotlib. As such, I am sure that someone can make this code much more terse. At any rate, this should clearly demonstrate how to go about solving your problem. >>> import pylab >>> fig = pylab.figure() >>> pylab.axis(‘off’) (0.0, … Read more

Removing white space around a saved image

You can remove the white space padding by setting bbox_inches=”tight” in savefig: plt.savefig(“test.png”,bbox_inches=”tight”) You’ll have to put the argument to bbox_inches as a string, perhaps this is why it didn’t work earlier for you. Possible duplicates: Matplotlib plots: removing axis, legends and white spaces How to set the margins for a matplotlib figure? Reduce left … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)