繁体   English   中英

Seaborn 岭图中未对齐的标签

[英]Misaligned labels in Seaborn ridge plot

我注意到,如果我在 Seaborn ridge plot example here中更改这条线g.figure.subplots_adjust(hspace=-0.25) ,标签不会很好地对齐。 例如,如果我将行更改为g.figure.subplots_adjust(hspace=-0.9) ,这就是我在下图中得到的。

尝试使用g.figure.subplots_adjust(hspace=-0.9)更多地重叠直方图时,有没有办法匹配标签?

在此处输入图像描述

对于 y 轴标签,字符串是单独创建的,y 轴位置是手动确定的。 所以改变 ax.text() 中的 y 轴坐标将产生预期的结果。 我手动尝试过,0.045 似乎是最佳的。 您可以根据自己的喜好对其进行修改。

# Define and use a simple function to label the plot in axes coordinates
def label(x, color, label):
    ax = plt.gca()
    ax.text(0, .045, label, fontweight="bold", color=color,
            ha="left", va="center", transform=ax.transAxes)

在此处输入图像描述

暂无
暂无

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

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