简体   繁体   English

在 seaborn 中使用 FacetGrid 为所有方面重复 x 轴标签

[英]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.我正在使用此处介绍的FacetGrid示例,结果如下图。 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.在我的数据集中,有相当多的图,并且为每个面重复x轴标签会很方便,而不仅仅是在底部。

For this example, the values 62, ..., 76 should be repeated for each of the AJ facets.对于此示例,应为每个AJ面重复值62, ..., 76

在此处输入图片说明

The answer by Bazingaa works for matplotlib version 2.0.2. Bazingaa 的答案适用于 matplotlib 2.0.2 版。 For newer versions of matplotlib, using ax.tick_params() and setting labelbottom=True seems to work:对于较新版本的 matplotlib,使用ax.tick_params()并设置labelbottom=True似乎有效:

for ax in g.axes.flatten():
    ax.tick_params(labelbottom=True)

Just add the following lines after your def label(): function.只需在def label():函数后添加以下几行即可。 Although the plot doesn't look that good with the modification you want.虽然你想要的修改情节看起来不太好。

for ax in g.axes.flat:
    _ = plt.setp(ax.get_xticklabels(), visible=True)

Output输出

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM