【问题标题】:Show edges and faces of markers in legend在图例中显示标记的边缘和面
【发布时间】:2019-07-04 04:57:49
【问题描述】:

我有附图,我喜欢用

绘制的符号
ax.errorbar('mjd', 'aperMag3Ab', label='',        fmt='o',  color='k', ms=ms*1.4)
ax.errorbar('mjd', 'aperMag3Ab', label='WFCAM Y', fmt='o',  color='y', ms=ms)

基本上一共重复了八次。我目前得到的传说:

plt.legend(loc="upper left", ncol=2, fontsize=labelsize/1.4, frameon=True)

如何在图例中获得外部黑色圆圈(用于 WFCAM 标签)和内部黑色六边形(用于 VIRCAM 标签)?

【问题讨论】:

标签: python matplotlib plot label legend


【解决方案1】:

我无权访问您的数据,但如果您在图中明确设置了 fmtmarkeredgewidthmarkeredgecolor,它也应该显示在图例中。

作为一个最小的工作示例:

import matplotlib.pyplot as plt
fig, ax = plt.subplots()

ax.errorbar([0], [0], yerr = [0.25], label='WFCAM Y', fmt='o', markeredgecolor ='black', markeredgewidth = 1,  color='y', ms=10)
ax.errorbar([0], [1], yerr = [0.25], label='WFCAM Y', fmt='p', markeredgecolor ='black', markeredgewidth = 1,  color='r', ms=10)
plt.legend()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-16
    • 2013-10-24
    • 1970-01-01
    • 1970-01-01
    • 2016-01-28
    • 1970-01-01
    • 2020-02-09
    相关资源
    最近更新 更多