[英]How to plot separate bar in bar graph for repeated values using Matplotlib?
Given a dataset:给定一个数据集:
x = [3, 2, 4, 6, 7]
y = ['a','a','b','b','c']
Here variables a
and b
are repeated twice.这里变量
a
和b
重复了两次。 My requirement is to plot the bar graph for each variable and for variables a and b, we need a separate bar for each a and b.我的要求是 plot 每个变量和变量 a 和 b 的条形图,我们需要为每个 a 和 b 单独的条形图。
I was trying to plot a horizontal bar graph using the code:我正在尝试使用代码 plot 水平条形图:
plt.barh(y, x)
Here the value of a
and b
are stacked and plotted in a single bar.这里
a
和b
的值被堆叠并绘制在一个条形图中。 Please help with this.请帮忙解决这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.