如何制作不同高度、具有一定公共空间百分比的四条形图

2024-10-05 13:23:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我有100天的原始数据。四种方法确定了不同的有用天数数据

raw_days = 100
# Useful days identified by different methods
Met1 = 92 
Met2 = 93 
Met3 = 96 
Met4 = 91
commondays = 88 # Number of common useful days in four methods

我想用条形图表示上述信息。我不知道这是否可能。最后,我想看到的是一个条形图,如下图所示

enter image description here


Tags: 数据方法原始数据rawbydaysusefulmethods
1条回答
网友
1楼 · 发布于 2024-10-05 13:23:18

我将回答部分问题,并将有关注释栏的部分留给您。您可以参考this question以获取注释

raw_days = 100
# Useful days identified by different methods
Met1 = 92 
Met2 = 93 
Met3 = 96 
Met4 = 91
commondays = 88 

plt.bar(range(4), [Met1, Met2, Met3, Met4], color='r', ec='k')
plt.bar(range(4), [commondays]*4, color='w', hatch='/', ec='k', label='common useful \ndays in four methods')
plt.xticks(range(4), ['Met%i'%i for i in range(1, 5)])
plt.yticks([])
plt.legend(loc=(1.05, 0.5))
plt.ylabel('Useful days')

enter image description here

相关问题 更多 >

    热门问题