【问题标题】:How to customize titles and y labels in a Seaborn relplot如何在 Seaborn relplot 中自定义标题和 y 标签
【发布时间】:2021-05-05 01:23:44
【问题描述】:

我目前有一个 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)

创建了这个图。

我想用这个数字做两件事。首先,我想删除所有子情节标题。其次,我想将每个 y 标签(甚至是内部标签)设置为 "Oxide" + " Wt %",但也不知道该怎么做。

【问题讨论】:

    标签: python matplotlib graph seaborn data-science


    【解决方案1】:

    您可以直接从更喜欢的 FacetGrid 对象中设置它们:

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

    您不需要遍历轴,这些方法将它们设置在所有方面。

    【讨论】:

      【解决方案2】:

      你可以遍历harker.axes

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

      【讨论】:

      • 如果有人想独立自定义每个 y 标签或标题,这是可以使用的答案。
      猜你喜欢
      • 2020-12-10
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 2016-03-29
      • 1970-01-01
      • 1970-01-01
      • 2020-02-17
      • 1970-01-01
      相关资源
      最近更新 更多