首页 » 闲聊时间 » 这十年

这十年

1316 0
<code>import matplotlib.pyplot as plt
categories = &#91;'2024', '2023', '2022', '2021', '2020', '2019', '2018', '2017', '2016', '2015']
values1 = &#91;19, 19, 19, 21, 23, 25, 25, 25, 25, 25]
values2 = &#91;4.5, 5.5, 6.5, 10, 13.5, 17, 19, 21, 23, 25]
values3 = &#91;27, 25.5, 24, 31, 38, 45, 40, 35, 30, 25]
values4 = &#91;25, 25, 25, 25, 25, 25, 25, 25, 25, 25]
plt.barh(categories, values1, label='\u6211\u4eec\u7684\u751f\u5b58\u6210\u672c')
plt.barh(categories, values2, label='\u6211\u4eec\u7684\u7ed3\u4f59', left=values1)
plt.barh(categories, values3, label='\u4ed6\u4eec\u7684\u7ed3\u4f59', left=&#91;v1+v2 for v1, v2 in zip(values1, values2)])
plt.barh(categories, values4, label='\u4ed6\u4eec\u7684\u751f\u5b58\u6210\u672c', left=&#91;v1+v2+v3 for v1, v2, v3 in zip(values1, values2, values3)])
plt.rcParams&#91;'font.sans-serif'] = 'Microsoft YaHei'
plt.title('\u8fd9\u5341\u5e74')
plt.legend(loc='lower right', bbox_to_anchor=(1, 0))
plt.show()</code>
文章评分1次,平均分5.0

本文原始地址:https://www.tiandiyoyo.com/2024/06/tenyears/
本站所有文章,除了特别注明外,均为本站原创,转载请注明出处来自www.tiandiyoyo.com

评论前先开启评论开关: