[英]Matplotlib Bar Plot Grouping Subplots
I'm currently generating this plot: 我目前正在生成此图:
But as you can see, it is taking taking the items from arrays below and spreading them across the xticks. 但是正如您所看到的,它是从下面的数组中获取项目并将它们散布到xticks中的。
[array([ 1.77009257, 1.57980963, 0.31896943, 0.01874767]), array([ 1.02788175, 0.99604306])]
[array([ 0.20091287, 0.14682076, 0.03212798, 0.00187477]), array([ 0.09545977, 0.11318596])]
What I want is to create a cluster of all four items from the first array over the xtick -2wks and a cluster of the two items of the next array over xtick -1wk. 我想要的是从xtick -2wks上的第一个数组中创建所有四个项的群集,并在xtick -1wk上的下一个数组中创建两个项的群集。
Bonus points if you can then give each bar in a given cluster the corresponding label from these arrays. 如果可以在给定群集中的每个条形上赋予这些数组相应的标签,则可以得到加分。
[Index([u'AL GAINESVILLE LOCK', u'AL GREENSBORO', u'AL HIGHLAND HOME', u'AL BREWTON 3 SSE'],dtype='object', name=u'StateCity'), Index([u'AL GREENSBORO', u'AL GAINESVILLE LOCK'], dtype='object', name=u'StateCity')]
You might be best off using pandas
plot
for this. 为此,最好使用
pandas
plot
。 The second example here looks very similar to what you would like to achieve if I understand you correctly. 如果我正确理解, 这里的第二个示例看起来与您想要实现的目标非常相似。
If you transpose your data so that the index
you show below makes up the columns
and your xticks
make up the new index
, you should get what you are looking for. 如果对数据进行转置,以使下面显示的
index
构成各columns
而xticks
构成新的index
,则应该得到所需的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.