Python数据可视化与matplotlib(2)

  • Post author:
  • Post category:python


各种图形代码

1.堆积面积图

import numpy as np

import matplotlib.pyplot as plt

x = np.arange(6)

y1 = np.array([1,2,3,4,5,6])

y2 = np.array([1,3,5,7,9,4])

y3 = np.array([2,4,7,8,9,5])

plt.stackplot(x, y1, y2, y3)

plt.title(‘2020080603021’)

plt.show()

在这里插入图片描述

2.直方图

import numpy as np

import matplotlib.pyplot as plt

scores = np.random.randint(0, 100, 50)

plt.hist(scores, bins=8, histtype=‘stepfilled’)

plt.title(‘2020080603021’)

plt.show()

在这里插入图片描述

3.灰度直方图

import numpy as np

import matplotlib.pyplot as plt

random_state = np.random.RandomState(19680801)

random_x = random_state.randn(10000)

plt.hist(random_x, bins=25)

plt.title(‘2020080603021’)

plt.show()

在这里插入图片描述

4.饼图

import numpy as np

import matplotlib.pyplot as plt

import matplotlib as mpl



版权声明:本文为yiyuyunyan原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。