Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repeating x axis labels for all facets using FacetGrid in seaborn

I am working with the FacetGrid example presented here that results in the plot below. In my data set, there is quite a lot of plots, and it would be convenient to have the x axis labels repeated for each facet, not only at the bottom.

For this example, the values 62, ..., 76 should be repeated for each of the A-J facets.

enter image description here

like image 715
Krzysztof Słowiński Avatar asked Sep 05 '18 09:09

Krzysztof Słowiński


People also ask

What is FacetGrid in Seaborn?

FacetGrid object takes a dataframe as input and the names of the variables that will form the row, column, or hue dimensions of the grid. The variables should be categorical and the data at each level of the variable will be used for a facet along that axis.

What is the primary goal when using FacetGrid in Seaborn?

FacetGrid() : FacetGrid class helps in visualizing distribution of one variable as well as the relationship between multiple variables separately within subsets of your dataset using multiple panels.

How do I get rid of Xticks in Seaborn?

Plot the rectangular data as a color-encoded matrix. Use tick_params() for changing the appearance of ticks and tick labels. Use left=false and bottom=false to remove the tick marks.


1 Answers

The answer by Bazingaa works for matplotlib version 2.0.2. For newer versions of matplotlib, using ax.tick_params() and setting labelbottom=True seems to work:

for ax in g.axes.flatten():
    ax.tick_params(labelbottom=True)
like image 50
DavidG Avatar answered Sep 16 '22 21:09

DavidG