很久没做笔记
这是关于画图表的实践

错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

fruits = ['2014', '2015', '2016', '2017','2018', '2019', '2020', '2021','2022', '2023']
counts = [137646, 138326, 139232, 140011,140541,141008,141212,141260,141175,140967]
bar_labels = ['red', 'blue', '_red', 'orange']
bar_colors = ['tab:red', 'tab:blue', 'tab:red', 'tab:orange']

ax.bar(fruits, counts, label=bar_labels, color=bar_colors)

ax.set_ylabel('人口数(万)')
ax.set_title('2014-2023中国人口数量')
ax.legend(title='年份')

plt.show()

更改后:

1