我正在尝试使用 plotnine 生成一些图表。我导入所需的库:
from plotnine import *
from plotnine.data import mpg
然后,如果我在 PyCharm 中运行以下代码,我会收到一条警告消息,窗口图 显示“无应答”消息,我被迫重新启动 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。
最佳答案
我有类似的问题,但在 MacOS 上使用 PyCharm 的商业添加。
来自 this github issue和 this JetBrains issue ,看起来它可能与 PyCharm 错误有关。
关于python-3.x - plotnine:UserWarning:在主线程之外启动 Matplotlib GUI 可能会失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64066186/