Delete frame while saving axes in subtitles

I create a figure with 3 subheadings and wonder if there is a way to remove the frame around them while keeping the axes in place?

+4
source share
3 answers

If you want to remove axial spikes, but not other information (ticks, tags, etc.), you can do it like this:

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 simply, using seaborn :

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))

seaborn.despine(left=True, bottom=True, right=True)

Both approaches will help you:

enter image description here

+5
source

You can achieve something similar using the axis('off')axis descriptor method . This is what you need? (example code below the picture).

subplots without axes shown

fig, ax = plt.subplots(7,1)

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.axis('off')

plt.show()
+2
source

plt.box(on=None) () , .

plt.axis('off') , .

, .

+2
source

All Articles