Seaborn PairGrid: show axes tick-labels for each subplot

5k views Asked by At

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)
3

There are 3 answers

1
Antoine Gautier On BEST ANSWER

Answer found here: Show y_ticklabels in a seaborn pairplot with shared axes

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.

1
art On

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

0
Filippo Vitale On

I would call .set on the pairplot PairGrid

g = sns.pairplot(...)
g.set(xticklabels=[], yticklabels=[])