我正在尝试使用 plotnine 生成一些图表。我导入所需的库:
from plotnine import *
from plotnine.data import mpg
然后,如果我在 PyCharm 中运行以下代码,我会收到一条警告消息,窗口图会显示“No answer”消息,我被迫重新启动 python 终端:
(ggplot(mpg) # defining what data to use
+ aes(x='class') # defining what variable to use
+ geom_bar(size=20) # defining the type of plot to use
)
<ggplot: (150517199824)>
C:\Users\alvaromc317\miniconda3\envs\general\lib\site-packages\plotnine\ggplot.py:363: UserWarning: Starting a Matplotlib GUI outside of the main thread will likely fail.
但是,如果我从 windows cmd 终端启动一个 python 终端并运行与以前相同的脚本,我不会收到任何错误消息,并且我可以看到没有问题的图。
发生了什么,如何在 pycharm 中使用 plotnine?
如果需要,我使用 Windows 10 机器和基于 miniconda 的 python 3x 工作。