各种图形代码
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