I'm not sure of a way to do this in seaborn
, but you can play with the matplotlib Axes
instances to do this.
For example, here we'll use setp
to set the xticklabels
to visible for all axes in the FacetGrid
(g
). Note that I also set the rotation here too, since seaborn would not rotate the ticklabels
on the upper row.
Finally, I have increased the space between subplots to allow room for the tick labels using subplots_adjust
.
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from io import StringIO
the_file_name = StringIO(u"""
Company,Date,Value
ABC,08/21/16,500
ABC,08/22/16,600
ABC,08/23/16,650
DEF,08/21/16,625
DEF,08/22/16,675
DEF,08/23/16,680
GHI,08/21/16,500
GHI,08/22/16,600
GHI,08/23/16,650
JKL,08/21/16,625
JKL,08/22/16,675
JKL,08/23/16,680
""")
df = pd.read_csv(the_file_name)
g = sns.factorplot(data=df,
x='Date',
y='Value',
col='Company',
col_wrap=2,
sharey=False)
g.set_xlabels('')
g.set_ylabels('product count')
for ax in g.axes:
plt.setp(ax.get_xticklabels(), visible=True, rotation=45)
plt.subplots_adjust(hspace=0.3)
plt.show()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…