Pyplot 文本(Text)

  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. # Fixing random state for reproducibility
  4. np.random.seed(19680801)
  5. mu, sigma = 100, 15
  6. x = mu + sigma * np.random.randn(10000)
  7. # the histogram of the data
  8. n, bins, patches = plt.hist(x, 50, density=True, facecolor='g', alpha=0.75)
  9. plt.xlabel('Smarts')
  10. plt.ylabel('Probability')
  11. plt.title('Histogram of IQ')
  12. plt.text(60, .025, r'$\mu=100,\ \sigma=15$')
  13. plt.axis([40, 160, 0, 0.03])
  14. plt.grid(True)
  15. plt.show()

Pyplot 文本示例

参考

此示例显示了以下函数、方法、类和模块的使用:

  1. import matplotlib
  2. matplotlib.pyplot.hist
  3. matplotlib.pyplot.xlabel
  4. matplotlib.pyplot.ylabel
  5. matplotlib.pyplot.text
  6. matplotlib.pyplot.grid
  7. matplotlib.pyplot.show

下载这个示例