a11*_*a11 6 python seaborn facet-grid
在 Seaborn FacetGrid 中,如何让 y 轴刻度标签显示在所有子图中,无论是否显示sharey=True?
tips = sns.load_dataset("tips")
g = sns.FacetGrid(tips, col="time", row="sex")
g.map(sns.scatterplot, "total_bill", "tip")
Run Code Online (Sandbox Code Playgroud)
以下尝试返回错误AttributeError: 'FacetGrid' object has no attribute 'flatten'
for axis in g.flatten():
for tick in axis.get_yticklabels():
tick.set_visible(True)
Run Code Online (Sandbox Code Playgroud)
for axis in g.axes.flat:
axis.tick_params(labelleft=True)
Run Code Online (Sandbox Code Playgroud)
这在这里对我有用。
for axis in axes.flatten():
for tick in axis.get_yticklabels():
tick.set_visible(True)
Run Code Online (Sandbox Code Playgroud)
尝试循环遍历每个图的每个轴并手动强制刻度标签可见。