Clearing a subplot in Matplotlib

ax.clear() clears the axes. That is, it removes all settings and data from the axes such that you are left with an axes, just as it had been just created. ax.axis(“off”) turns the axes off, such that all axes spines and ticklabels are hidden. ax.set_visible(False) turns the complete axes invisible, including the data that is … Read more

Removing frame while keeping axes in pyplot subplots

If you want to remove the axis spines, but not the other information (ticks, labels, etc.), you can do that like so: fig, ax = plt.subplots(7,1, sharex=True) t = np.arange(0, 1, 0.01) for i, a in enumerate(ax): a.plot(t, np.sin((i + 1) * 2 * np.pi * t)) a.spines[“top”].set_visible(False) a.spines[“right”].set_visible(False) a.spines[“bottom”].set_visible(False) or, more easily, using seaborn: … Read more

Manipulation on vertical space in matplotlib subplots

As you said in your question hspace reduces the vertical spacing between subplots. The equivalent for horizontal spacing between subplots is wspace. Below is an example: x = np.linspace(0, 2 * np.pi, 400) y = np.sin(x ** 2) fig, ((ax1,ax2),(ax3,ax4)) = plt.subplots(nrows=2, ncols=2) fig.tight_layout() ax1.plot(x, y) ax2.scatter(x, y) ax3.scatter(x, y) ax4.scatter(x, y) fig.subplots_adjust(wspace=0.2) plt.show() Using … Read more

matplotlib: alignment of legend title

You may align the complete legend box setting leg._legend_box.align. This aligns everything inside the legend box, but the effect is the desired one to have the title on either side of the box instead of the center. Left aligned leg = plt.legend(title=”Title”) leg._legend_box.align = “left” Right aligned leg = plt.legend(title=”Title”) leg._legend_box.align = “right”

matplotlib values under cursor [duplicate]

You simply need to re-assign ax.format_coord. See this example from the documentation. (code lifted directly from example) “”” Show how to modify the coordinate formatter to report the image “z” value of the nearest pixel given x and y “”” import numpy as np import matplotlib.pyplot as plt import matplotlib.cm as cm X = 10*np.random.rand(5,3) … Read more

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