【问题标题】:Show a Pandas plot from a script从脚本显示熊猫图
【发布时间】:2015-11-15 02:09:27
【问题描述】:

我有一个脚本(不是 IPython 笔记本),它在最后生成一个图(通过 pandas DataFrame)。我的问题是没有显示这样的情节。

灵感来自this 我试过了

fig, ax = plt.subplots()
my_dataframe.plot(ax=ax)
ax.show()

这不起作用。我可以展示我的情节的唯一方法是:

plt.figure()
my_dataframe.plot()
plt.show()

但这也带来了一个我不想拥有的空洞。

【问题讨论】:

    标签: python pandas plot


    【解决方案1】:

    你试过了吗

    fig, ax = plt.subplots()
    my_dataframe.plot(ax=ax)
    plt.show() # plt in place of ax
    

    【讨论】:

    • 对于不习惯这些缩写的人:plt referers to import matplotlib.pyplot as plt
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-07
    • 2014-11-05
    • 1970-01-01
    • 2023-02-04
    • 2016-03-24
    相关资源
    最近更新 更多