【问题标题】:I Run the code,there are no errors but nothing shows up [duplicate]我运行代码,没有错误,但没有显示[重复]
【发布时间】:2019-06-17 06:07:06
【问题描述】:

我不知道出了什么问题,但没有出现错误,但什么也没发生... 我试图以图形方式表示 pi 的前 100.000 位中每个数字 (0-9) 的出现频率(例如,在直方图中)

import numpy as np
import matplotlib.pyplot as plt
from numpy import *
from mpmath import *

mp.dps=100000
data = (str(pi))
plt.hist(data, bins=10, color='steelblue')

它应该显示一个包含 10 个 bin 的直方图以及每个 bin 中每个数字的频率,但没有显示任何内容,但没有打印错误消息。

【问题讨论】:

  • 为什么要导入两次numpy?你也应该在最后尝试plt.show()

标签: python numpy matplotlib plot histogram


【解决方案1】:

您忘记添加: plt.show()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-06
    • 2023-01-31
    相关资源
    最近更新 更多