简体   繁体   English

Matplotlib.pyplot 不会显示 plot

[英]Matplotlib.pyplot won't show plot

I recently downloaded python on my new computer, however when I try to plot something in matplotlib the plot doesn't show.我最近在我的新计算机上下载了 python,但是当我尝试 plot 时 matplotlib Z32FA6E1B78A9D42AA4CZ 中的某些内容没有显示。 Even the example beneath doesn't work.即使下面的示例也不起作用。 I am running this in spyder via anaconda.我通过 anaconda 在 spyder 中运行它。

import matplotlib.pyplot as plt
x=[1,2,3]
y=[2,3,4]

plt.plot(x,y)
plt.show()

What can I do?我能做些什么?

EDIT: I figured it out, it was just a simple problem.编辑:我想通了,这只是一个简单的问题。 If you struggle with the same, make sure you have checked off for plots when going to View - Panes - plots or press shift + cmd + G on mac.如果您遇到同样的问题,请确保您在查看 - 窗格 - 绘图或在 mac 上按 shift + cmd + G 时检查了绘图。

Your code is fine.你的代码很好。 This is probably an issue with your IDE.这可能是您的 IDE 的问题。 You might want to ask this question with regards to the specific IDE you are using.您可能想就您正在使用的特定 IDE 提出这个问题。 For example if you ran this is Jupyter notebook the issue might be solved with a %matplotlib inline例如,如果您运行的是 Jupyter notebook,则可以使用%matplotlib inline解决问题

If you are running it on the python shell itself an external window should appear displaying your plot.如果您在 python shell 上运行它,则外部 window 应该会显示您的 Z32FA6E1B78A9D4028953E605。 If you are using an IDE like pycharm you might need to configure certain settings to get the external window to appear.如果您使用的是 IDE,例如 pycharm,您可能需要配置某些设置以使外部 window 出现。

Hope this helps!希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM