python - Matplotlib not rendering chart in Jupyter (Conda) - Stack Overflow

I just installed the most recent version of Anaconda (24.11.3).I'm trying to do a simple line ch

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
  • Never post screenshot of code or logs this is counter productive while wasting resources and preventing the community to help you efficiently. Instead copy paste and format. – jlandercy Commented Mar 25 at 12:08
  • @jlandercy, got it will do in the future. Thank you. – jpanknin Commented Mar 25 at 12:26
  • What happens if you just remove %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 need plt.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:46
  • To make it easy to test what should happen, I suggest using MyBinder sessions for modern Jupyter without needing to touch your own machine. One of the Jupyter developers keeps a fairly up to date offering here. For example, JupyterLab 4.3 on Binder is one of the most recent. Launch that in your browser by hitting 'launch 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
 |  Show 1 more comment

1 Answer 1

Reset to default 1

You 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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744198538a4562770.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信