I just installed the most recent version of Anaconda (24.11.3). I'm trying to do a simple line chart using matplotlib, but am just getting the text output instead of the actual chart.
I tried this exact same code in both Jupyter Notebook and JupyterLab (both opened through Anaconda Navigator) and am getting the same text output instead of the chart itself in both.
These are the matplotlib versions that are installed in conda.
Anyone have any idea why this is happening and how to fix it?
I just installed the most recent version of Anaconda (24.11.3). I'm trying to do a simple line chart using matplotlib, but am just getting the text output instead of the actual chart.
I tried this exact same code in both Jupyter Notebook and JupyterLab (both opened through Anaconda Navigator) and am getting the same text output instead of the chart itself in both.
These are the matplotlib versions that are installed in conda.
Anyone have any idea why this is happening and how to fix it?
Share Improve this question asked Mar 25 at 11:49 jpankninjpanknin 1172 gold badges3 silver badges12 bronze badges 6 | Show 1 more comment1 Answer
Reset to default 1You are missing plt.show()
. Your code returns a Line2D object and that is what the line below the code block states (also mentioning the position in your computer's memory).
This code works just fine:
x = np.linspace(-10, 10, 100)
y = np.sin(x)
plt.plot(x, y, marker="x")
plt.show()
Note that you can also have interactive plots with %matplotlib notebook
%matplotlib inline
like in this very similar question stackoverflow/questions/79366461/…? – Matt Pitkin Commented Mar 25 at 14:37%matplotlib inline
is the default now. It is not needed if you aren't switching anything with%matplotlib
otherwise. Not sure though why it would need to be removed other than something about your installation seems flawed as it is. You shouldn't needplt.show()
that it seems you checked off as solving it if you truly have a fresh working installation. Had you restarted everything before this test? And I mean everything. The entire browser and machine. Also, done a hard refresh on your brower page where the notebook is? (On a MAc in Chrome, Shift + Comand +r
does it.) – Wayne Commented Mar 25 at 15:46launch binder
'. When the session comes up, open a new notebook and run%pip install numpy matplotlib
to install those two packages. Restart the kernel and run the code ... – Wayne Commented Mar 25 at 16:00