我的Python新手,试图重现如下图: 图表在Python 3.5.2与希腊字母(胶乳)
MWE是:
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
mu, sigma = 100, 15
x = mu + sigma*np.random.randn(10000)
# the histogram of the data
n, bins, patches = plt.hist(x, 50, normed=1, facecolor='green',
alpha=0.75)
# add a 'best fit' line
y = mlab.normpdf(bins, mu, sigma)
l = plt.plot(bins, y, 'r--', linewidth=1)
plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$')
plt.axis([40, 160, 0, 0.03])
plt.grid(True)
plt.show()
和输出
但是,希腊字母不能正确显示。我可能在这里缺少一些基本的东西。如果有人指导我重现Python 3.5.2
中的原始图形,我将非常感激。
编辑
我使用和Python 3.5.2
通过Python 2.4.1
IDLE
上Ubuntu 16.10
。
使用Python 3.5.2通过IPython/Anaconda(并通过闲置测试)。将代码复制到提示中时,它工作得很好。你从哪里运行你的? – internetional
@internetional:请参阅我的编辑。任何想法,请。 – MYaseen208
我会尝试IPython,如果我是你。我觉得它比IDLE更稳定。可悲的是我没有什么线索,甚至更少的想法如何解决你的问题。 – internetional