python - matplotlib图例中符号左侧的文字

标签 python matplotlib legend

<分区>

是否有任何内置函数/方法或简洁的方法可以将文本放在图例中标记/符号的左侧?

最佳答案

这可以通过将 matplotlib.pyplot.legend 的参数 markerfirst 设置为 False 来完成。

markerfist : bool If True, legend marker is placed to the left of the legend label. If False, legend marker is placed to the right of the legend label. Default is True.

类似的东西:

t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)

fig, ax = plt.subplots()
ax.plot(t, s, label='sine')
ax.legend(markerfirst=False)

plt.show()

我希望这就是您要找的:)

关于python - matplotlib图例中符号左侧的文字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54969227/

相关文章:

r - 使用 par 时图例框宽度不正确

python - 在外部文件中存储字典、正则表达式和变量的最佳方式?

python - openpyxl:将日期转换为数字

python - 无法在 conda 中安装 matplotlib

python - 如何在pyplot中自动标注最大值

javascript - 图外的 JQPlot 图例

python - 反转图例的顺序

Python高斯核密度计算新值的分数

python - 无法使用 OpenMPI : Cannot compile MPI programs 安装 mpi4py

python - seaborn 热图中的离散图例