简体   繁体   English

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

[英]Matplotlib : Consistent Y-Axis across 4 Separate Line Plots

I have 4 dictionaries which are dictionaries of lists. 我有4个字典,它们是列表的字典。
This is being used to plot the volume per month of various entities as multiple line plots. 这用于将多个实体的每月交易量绘制为多条线图。
Each dictionary key has the value as a list of 12 values each representing the volume of the corresponding month 每个字典键的值都是12个值的列表,每个值代表相应月份的数量

I have 4 dictionaries : d1, d2, d3 and d4. 我有4个字典:d1,d2,d3和d4。
Sample value of a dictionary element - [239, 138, 271, 175, 29, 0, 0, 0, 0, 2, 24, 62] 字典元素的样本值- [239, 138, 271, 175, 29, 0, 0, 0, 0, 2, 24, 62]
How do I ensure the same Y-Axis value (sharey ?) across all 4 ? 如何确保所有4个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)

我认为使用yticks属性如下:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM