简体   繁体   中英

Misaligned labels in Seaborn ridge plot

I noticed that if I change this line g.figure.subplots_adjust(hspace=-0.25) in Seaborn ridge plot example here , the labels don't align well. For example if I change the line to g.figure.subplots_adjust(hspace=-0.9) , this is what I get in picture below.

Is there a way to match the labels when trying to overlap histograms more using g.figure.subplots_adjust(hspace=-0.9) ?

在此处输入图像描述

For the y-axis labels, the strings are created individually and the y-axis position is determined manually. So changing the y-axis coordinates in ax.text() will produce the intended result. I tried it manually and 0.045 seemed optimal. You can modify it to your liking.

# 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)

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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