我的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