Search code examples
pythonmatplotlibseabornrelplot

How to customize titles and y labels in a 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.

enter image description here

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.


Solution

  • 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.