The sns.FacetGrid
class has a private attribute _margin_titles_texts
which is a list containing the matplotlib.text.Annotation
objects that make the margin titles. We can iterate through those and call the set_color
method on each to change the text colour.
import seaborn as sns
p = sns.load_dataset("penguins")
grid = sns.displot(
data=p,
x="flipper_length_mm",
col="species",
row="sex",
facet_kws=dict(margin_titles=True),
)
for margin_title in grid._margin_titles_texts:
margin_title.set_color("red")
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.