简体   繁体   中英

How to customize titles and y labels in a Seaborn relplot

I currently have a seaborn relplot

harker = sns.relplot(data = majorsLong, x = "SiO2", y = "Wt %", palette = colors,
                     markers = marks, style = "Lithology", hue = "Lithology",
                     kind = "scatter", col = "Oxide", col_wrap = 2, s = 150,
                     facet_kws = {'sharey': False, 'sharex': True},
                     linestyle = "None", legend = False)

Which creates this figure.

在此处输入图像描述

I want to do two things with this figure. First, I want to remove all of the subplot titles. Second, I want to set each y label (even the interior ones) to be "Oxide" + " Wt %" , but can't figure out how to do either.

You can set those directly from you harker FacetGrid object:

harker.set_titles("")
harker.set_ylabels("My Label", clear_inner=False)

You don't need to iterate through the axes, these methods set them on all facets.

You can iterate through harker.axes :

for ax in harker.axes.flatten():
    ax.set_title('')
    ax.set_ylabel('Oxide + Wt %')

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