Repeating x axis labels for all facets using Facet

2020-06-17 04:52发布

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

2条回答
姐就是有狂的资本
2楼-- · 2020-06-17 05:28

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)
查看更多
手持菜刀,她持情操
3楼-- · 2020-06-17 05:31

Just add the following lines after your def label(): function. 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

enter image description here

查看更多
登录 后发表回答