I've the following code which creates the plot you can see in the picture:
g = sns.FacetGrid(data, col="Provincia",col_wrap=6,size=2.5)
g.map(sns.barplot, "Anio", "Diff");
g.set_axis_labels("Año", "Porcentaje de aumento");
for ax in g.axes.flat:
_ = plt.setp(ax.get_yticklabels(), visible=True)
_ = plt.setp(ax.get_xticklabels(), visible=False)
_ = plt.setp(ax.get_xticklabels()[0], visible=True)
_ = plt.setp(ax.get_xticklabels()[-1], visible=True)
The problem, as you can see in the picture, is that the x ticks collapse with the col name below. What is the proper way to increase this space in order to fix this?
tight layout
You can use
tight_layout
to automatically adjust the spacingsor, if you have
matplotlib.pyplot
imported asplt
,subplots adjust
You can use
plt.subplots_adjust
to manually set the spacings between subplots,where
hspace
is the space in height, andwspace
is the space width direction.gridspec keyword arguments
You could also use
gridspec_kws
in theFacetGrid
initialization,However, this can only be used if
col_wrap
is not set. (So it might not be an option in the particular case from the question).