如何在PyCharm中显示图表?

huangapple go评论118阅读模式
英文:

How can I display plots in PyCharm?

问题

我在PyCharm中出现了可视化图表的问题,但尚未找到解决方案。有人知道如何在PyCharm中查看图表吗?

import matplotlib.pyplot as plt
plt.style.use('ggplot')
df['Score'].value_counts().sort_index().plot(
    kind='bar',
    title='Count of Reviews by Stars',
    figsize=(10, 5)
)
英文:

I have a problem visualizing plots in pycharm, and I haven't found a solution yet.
Does anyone know how to view plots in PyCharm?

import matplotlib.pyplot as plt
plt.style.use('ggplot')
df['Score'].value_counts().sort_index().plot(
    kind='bar',
    title='Count of Reviews by Stars',
    figsize=(10, 5)
)

答案1

得分: 1

你可以在你的脚本末尾添加plt.show()吗?

import matplotlib.pyplot as plt
plt.style.use('ggplot')
df['Score'].value_counts().sort_index().plot(kind='bar', title='Count of Reviews by Stars',
                                              figsize=(10, 5))
plt.show()
英文:

Can you add plt.show() at the end of your script?

import matplotlib.pyplot as plt
plt.style.use('ggplot')
df['Score'].value_counts().sort_index().plot(kind='bar', title='Count of Reviews by Stars',
                                                      figsize=(10, 5))
plt.show()

答案2

得分: 0

尝试将以下内容放在你的脚本顶部:

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
英文:

Try putting this at the top of your script:

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt

huangapple
  • 本文由 发表于 2023年2月19日 20:09:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75500042.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定