Seaborn PairGrid: show axes tick-labels for each subplot

本小妞迷上赌 提交于 2019-12-11 02:44:12

问题


With seaborn.PairGrid is there a way to show the axes tick-labels for each subplot? (an equivalent to sharex=False, sharey=False in case of seaborn.FacetGrid)

import pandas as pd
import numpy as np    
import seaborn as sns
import matplotlib.pyplot as plt

df = pd.DataFrame()
for n in ['a', 'b']:
    tmp = pd.DataFrame({'name': [n] * 100,
                        'prior': [1, 10] * 50,
                        'post': [1, 10] * 50})
    df = df.append(tmp)

g = sns.PairGrid(df, hue='name', diag_sharey=False)
g.map_offdiag(sns.regplot, fit_reg=False, x_jitter=.1)
g.map_diag(sns.distplot, kde=False)

回答1:


Answer found here: http://stackoverflow.xluat.com/questions/31094436/show-y-ticklabels-in-a-seaborn-pairplot

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

Where it is precised that _ = ... is here to suppress unwanted print out in interactive environments.




回答2:


Have you tried set a style with sns.set_style("ticks") ?

More details about controlling figure aesthetics: http://stanford.edu/~mwaskom/software/seaborn/tutorial/aesthetics.html



来源:https://stackoverflow.com/questions/30921164/seaborn-pairgrid-show-axes-tick-labels-for-each-subplot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!