我有熊貓數據幀「東風」分組條形圖熊貓
+--- -----+------------+-------------+----------+------------+-----------+
|avg_views| avg_orders | max_views |max_orders| min_views |min_orders |
+---------+------------+-------------+----------+------------+-----------+
| 23 | 123 | 135 | 500 | 3 | 1 |
+---------+------------+-------------+----------+------------+-----------+
什麼,我找現在是繪製分組棒形圖我的表 的意見(平均,最大值,最小值)並在一張單獨的條形圖中下單。
即在x軸上將存在視圖和訂單,距離 和3個條(avg,max,min)對視圖和訂單類似。
我附加了一個示例條形圖圖像,以瞭解條形圖的外觀。
我把下面的代碼從setting spacing between grouped bar plots in matplotlib但它不是爲我工作
plt.figure(figsize=(13,7), dpi=300)
groups = [[23,135,3],
[123,500,1]]
group_labels = ["views", "orders"]
num_items = len(group_labels)
ind = np.arange(num_items)
margin = 0.05
width = (1.-2.*margin)/num_items
s = plt.subplot(1,1,1)
for num, vals in enumerate(groups):
print "plotting: ", vals
# The position of the xdata must be calculated for each of the two data series
xdata = ind+margin+(num*width)
# Removing the "align=center" feature will left align graphs, which is what
# this method of calculating positions assumes
gene_rects = plt.bar(xdata, vals, width)
s.set_xticks(ind+0.5)
s.set_xticklabels(group_labels)
你能提供[MCVE]嗎? – IanS
@IanS檢查,我已附加代碼 – Shubham
它不起作用?錯誤信息? – IanS