如何解决在直方图条上显示所有颜色,而无需在python中添加权重
我正在使用以下代码在3个不同的数据集a
,b
和c
上制作5个小节。如何在每个栏中显示所有颜色。我不希望他们的价值加起来。例如,在第一栏中,如果Green
的值为1
,Yellow
为3
和Red
为6
最终值应为10
,而应为6
,但所有颜色都应显示为最终值。我不想使用透明颜色或仅使用条形轮廓。
import matplotlib.pyplot as plt
import numpy as np
a = [1,2,3,4,5]
b = [3,1,10,9]
c = [6,7,6]
ind = np.arange(len(a))
fig = plt.figure()
ax = fig.add_subplot(111)
ax.bar(x=ind,height=a,width=0.35,align='center',label='Green',facecolor='g')
ax.bar(x=ind,height=b,label='Yellow',facecolor='y')
ax.bar(x=ind,height=c,label='Red',facecolor='r')
plt.xticks(ind,a)
plt.xlabel('Coordination Number')
plt.ylabel('Frequency')
plt.legend()
plt.show()
解决方法
“ a”列的参考值为6,但尚不清楚它是否是最大值。我知道这是最大值,并计算出组成比。 我根据结果创建了一个堆积图。
new ApiScope()
{
Name = "shop.admin",DisplayName = "You can administrate the e-shop systems",Description = "Full admin access to the e-shop system.",Emphasize = false,Enabled = true,Required = false,UserClaims = new List<string>
{
//Custom user claims that should be provided when requesting access to this API.
//These claims will be added to the access token,not the ID-token!
"seniority",}
}
,
如果我正确理解了您的问题,您想显示所有颜色条,它们从相同的零基线开始,并在其对应的数字下分组吗?
我将使用https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_csv.html进行绘制,因为它提供了一种“偏移”组中每个小节的简便方法。要更改每个条的视觉偏移量,请更改df.to_csv(path + "file_01.csv",index=False)
函数的第二个参数。对于这种宽度组合,0.05似乎是一个不错的值。
dodge
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。