1

What I need should be straighforward but I couldn't find a solution. Say we draw the following seaborn.lmplot:

import seaborn as sns; sns.set_theme(color_codes=True)
tips = sns.load_dataset("tips")
g = sns.lmplot(x="total_bill", y="tip", col="day", hue="day",
               data=tips, col_wrap=2, height=3)

tips

I simply want to have a single label for the x-axis and a single label for the y-axis instead of two as currently.

In other words, that the word 'tip' be printed only one time on the centre left of the graph, and that the word 'total_bill' be printed only one time on the bottom centre of the graph.

How do we do this?

EDIT: there is a similar question here One shared x-axis label for Seaborn FacetGrid subplots (layouts/spacing?) yet it is not elaborated and does not solve my issue.

johnjohn
  • 716
  • 2
  • 9
  • 17
  • thanks @BigBen I had seen that answer but it is not very elaborated and I have several issues with it: I can add text, but the original labels stay where they are (so they overalp with my new labels), and also I cannot work out how to change the position of the added text. I think other users might want to know how to do this in detail, perhaps? – johnjohn Jan 20 '22 at 21:18
  • @BigBen I edited my question and now cite the one you mentioned – johnjohn Jan 20 '22 at 21:22
  • 1
    [`Axes.set_xlabel`](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_xlabel.html). Set one axis label as a blank string `''`, and [Figure labels: suptitle, supxlabel, supylabel](https://matplotlib.org/devdocs/gallery/subplots_axes_and_figures/figure_title.html) – Trenton McKinney Jan 20 '22 at 21:30
  • 1
    Since this has been closed, something like `g.set_axis_labels('', '')`, `g.fig.supxlabel('total_bill')` `g.fig.supylabel('tips')` – BigBen Jan 20 '22 at 21:36
  • @BigBen thanks so much, this worked like a charm. And your comment should be accepted as answer since the referenced answer is quite less developped than yours! – johnjohn Jan 20 '22 at 21:36
  • 1
    Actually it's even easier with `supxlabel` and `supylabel` (edited my comment). – BigBen Jan 20 '22 at 21:36
  • 1
    apologies, this one actually is quite helpful: https://stackoverflow.com/questions/16150819/common-xlabel-ylabel-for-matplotlib-subplots. Many thanks again in any case – johnjohn Jan 20 '22 at 21:39

0 Answers0