Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable the output of matplotlib pyplot

I have an array A of shape (1000, 2000). I use matplotlib.pyplot to plot the array, which means 1000 curves, using

import matplotlib.pyplot as plt plt(A) 

The figure is fine but there are a thousand lines of:

<matplotlib.lines.Line2D at 0xXXXXXXXX> 

Can I disable this output?

like image 704
shelper Avatar asked Aug 21 '12 13:08

shelper


People also ask

How do I stop matplotlib from showing?

Avoid Display With ioff() Method We can turn the interactive mode off using matplotlib. pyplot. ioff() methods. This prevents figure from being displayed.

What does PLT CLF () do in Python?

The clf() function in pyplot module of matplotlib library is used to clear the current figure.

Why is %Matplotlib inline?

Why matplotlib inline is used. You can use the magic function %matplotlib inline to enable the inline plotting, where the plots/graphs will be displayed just below the cell where your plotting commands are written. It provides interactivity with the backend in the frontends like the jupyter notebook.


1 Answers

This output is what the plt function is returning (I presume here you meant to write plt.plot(A)). To suppress this output assign the return object a name:

_ = plt.plot(A) 

_ is often used to indicate a temporary object which is not going to be used later on. Note that this output you are seeing will only appear in the interpreter, and not when you run the script from outside the interpreter.

like image 166
Chris Avatar answered Sep 22 '22 02:09

Chris