How to save a Seaborn plot into a file

The following calls allow you to access the figure (Seaborn 0.8.1 compatible): swarm_plot = sns.swarmplot(…) fig = swarm_plot.get_figure() fig.savefig(“out.png”) as seen previously in this answer. The suggested solutions are incompatible with Seaborn 0.8.1. They give the following errors because the Seaborn interface has changed: AttributeError: ‘AxesSubplot’ object has no attribute ‘fig’ When trying to access … Read more

Seaborn plots not showing up

Plots created using seaborn need to be displayed like ordinary matplotlib plots. This can be done using the plt.show() function from matplotlib. Originally I posted the solution to use the already imported matplotlib object from seaborn (sns.plt.show()) however this is considered to be a bad practice. Therefore, simply directly import the matplotlib.pyplot module and show … Read more

How to draw vertical lines on a given plot

The standard way to add vertical lines that will cover your entire plot window without you having to specify their actual height is plt.axvline import matplotlib.pyplot as plt plt.axvline(x=0.22058956) plt.axvline(x=0.33088437) plt.axvline(x=2.20589566) OR xcoords = [0.22058956, 0.33088437, 2.20589566] for xc in xcoords: plt.axvline(x=xc) You can use many of the keywords available for other plot commands (e.g. … Read more

Improve subplot size/spacing with many subplots

Please review matplotlib: Tight Layout guide and try using matplotlib.pyplot.tight_layout, or matplotlib.figure.Figure.tight_layout As a quick example: import matplotlib.pyplot as plt fig, axes = plt.subplots(nrows=4, ncols=4, figsize=(8, 8)) fig.tight_layout() # Or equivalently, “plt.tight_layout()” plt.show() Without Tight Layout With Tight Layout

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