Matplotlib:跨越4个独立线图的一致Y轴

时间:2015-08-03 06:36:47

标签: python dictionary pandas matplotlib graph

我有4个字典,是列表的字典。
这用于将各个实体的每月体积绘制为多个线图。
每个字典键具有作为12个值的列表的值,每个值表示相应月份的音量

我有4个词典:d1,d2,d3和d4。
字典元素的样本值 - [239, 138, 271, 175, 29, 0, 0, 0, 0, 2, 24, 62]
如何在所有4个<?p>中确保相同的Y轴值(共享?)

rcParams.update({'figure.autolayout': True})
plt.figure(figsize=(16,9), dpi=600)
plt.margins(0.075)
labels = []
plt.ylabel('Volume')
plt.xlabel('Months')
plt.title('Monthwise Volume per Queue', {'family' : 'Arial Black',
        'weight' : 'bold',
        'size'   : 22})
for i in d2:
    plt.plot([1,2,3,4,5,6,7,8,9,10,11,12], d2[i])
    labels.append(i)
    months = ["", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
plt.xticks(range(len(months)), months, rotation='vertical')
plt.legend(labels, ncol=1, loc='upper left', 
           bbox_to_anchor=[0.5, 1.1], 
           columnspacing=1.0, labelspacing=0.0,
           handletextpad=0.0, handlelength=1.5,
           fancybox=True, shadow=True)

1 个答案:

答案 0 :(得分:0)

我认为使用yticks属性,如:

plt.yticks(sharey) #where sharey is your list of values