1、普通风格

代码

import numpy as np
import matplotlib.pyplot as plt

rng = np.random.RandomState(27)
x = rng.normal(0, 1, 1000)

plt.hist(x, bins=9)

plt.show()

图形

Matplotlib 绘制定制的直方图

 

 

2 定制风格

代码

import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm

rng = np.random.RandomState(27)
x = rng.normal(0, 1, 10000)

plt.figure('赏尔', facecolor='azure')

n, bins, patches = plt.hist(x, bins=9, density=True, color='olive',
                            ec='w', align='mid' )

y = norm.pdf(bins, 0, 1)#拟合一条最佳正态分布曲线y
plt.plot(bins, y, 'r--')
plt.grid(which='both', ls='--', c='gray', alpha=0.3 )
plt.tight_layout()

plt.show()

图形

Matplotlib 绘制定制的直方图

 

。。。

相关文章:

  • 2021-04-30
  • 2022-12-23
  • 2021-10-07
  • 2021-11-16
  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
  • 2021-06-27
猜你喜欢
  • 2022-01-07
  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2022-02-03
  • 2022-12-23
相关资源
相似解决方案