0

I am visualization multi-time series lines and want to show without axis. I have tried multiple solutions from google but could not successful.

Here is the code:

f = plt.figure(frameon=False)
f.set_figwidth(4)
f.set_figheight(1)
plt.plot(x, linewidth=1.5)

Here is the output of the above code:

enter image description here

Any idea how to turn off this box from the lines?

Ahmad
  • 645
  • 2
  • 6
  • 21
  • 1
    Do you want to remove the entire box (all the 4 borders)? – Ravindra S Jun 24 '22 at 07:06
  • Does this answer your question? [Matplotlib plots: removing axis, legends and white spaces](https://stackoverflow.com/questions/9295026/matplotlib-plots-removing-axis-legends-and-white-spaces) – Jody Klymak Jun 24 '22 at 11:32

3 Answers3

4
for spine in plt.gca().spines.values():
    spine.set_visible(False)
    
ax = plt.gca()
ax.axes.xaxis.set_visible(False)
ax.axes.yaxis.set_visible(False)
Ravindra S
  • 6,302
  • 12
  • 70
  • 108
1

Finally I fixed the code via getting help from here and @Ravindra code.

Here is the final code:

 f.set_figwidth(4)
 f.set_figheight(1)
 plt.plot(x, linewidth=1.5)
 for spine in plt.gca().spines.values():
        spine.set_visible(False)
 frame1 = plt.gca()
 frame1.axes.get_yaxis().set_visible(False)
 frame1.axes.get_xaxis().set_visible(False)

Output:

enter image description here

Ahmad
  • 645
  • 2
  • 6
  • 21
0

Not a hundred percent sure what you mean by 'axis', but you can get rid of the frame by setting this:

plt.box(False)

enter image description here

So this is how it looks like:

Pickniclas
  • 349
  • 1
  • 8