Matplotlib vline 标签参数未显示 [英] Matplotlib vline label parameter not showing

查看:99
本文介绍了Matplotlib vline 标签参数未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 matplotlib 的 .vline 命令标记我的垂直线,但由于某种原因,label 参数在最终绘图上没有做任何事情/显示任何内容.有人知道如何显示标签吗?

I want to label my vertical lines with matplotlib's .vline command, but for some reason the label parameter doesn't do anything/show anything on the final plot. Does anyone know how to get the label to show?

plt.vlines(x=pah, ymin=0, ymax=0.6, colors='0.75', linestyles='dashed', label='PAHs')

一切都与标签分开.

非常感谢,

L

推荐答案

label关键字显示在图例中.您需要显式创建 legend 以查看图中的标签:

The label keyword is displayed in the legend. You need create the legend explicitly to see the label in the plot:

plt.vlines([1,2,3], 0, 1, label='test')
plt.legend()

这篇关于Matplotlib vline 标签参数未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆