python多行打印_为多行打印设置图例(在python中)

基于另一个问题(make-custom-legend-in-matplotlib和force-errorbars-to-render-last-with-matplotlib),我说得对。

第二个错误不应该发生,我认为zorder选项可能有错误。如果我只为错误栏选择较大的数字,则错误栏的绘图将继续隐藏。所以我必须为for循环中的行的zorder设置一个负数。

解决问题的方法是:fig = plt.figure()

ax = fig.add_subplot(1,1,1)

for i in range(71):

ax.plot(LTbvall[i],UXbvall[i],'-',color ='#C0C0C0',label = 'Perfis COPEX',zorder = -32)

ax.plot(LTbvall[3],UXavg,'b*-', label = u'média')

ax.errorbar(LTbvall[3],UXavg, yerr = yerr,ecolor='b',zorder = 10)

#Get artists and labels for legend and chose which ones to display

handles, labels = ax.get_legend_handles_labels()

display = (0,71)

ax.set_xlabel('Tempo (LT)')

ax.set_xlim(0,24)

ax.set_ylabel('Ux (m/s)')

ax.set_title('Vento neutro meridional calculado pelo modelo NWM (BV)')

ax.legend([handle for i,handle in enumerate(handles) if i in display],

[label for i,label in enumerate(labels) if i in display], loc = 'best')

fig.savefig(path[9] + 'Uxbvall_LT_nwm')

plt.clf()

plt.gcf()

plt.close()

输出如下:

ef0daa2499a4bcdfda85bad25aa50394.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值