Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove yaxis values from FacetGrid in seaborn

trying to remove the yaxis values.

d = pd.DataFrame({'row':['a']*9 + ['b']*9 + ['c']*9,                                        
                        'col': ['fft','krn','bycp']*9,                                          
                        'val':np.random.randn(27)})                                             
    print 'data', d     

Tried to grab figure not work.

    #f, (ax1, ax2) = plt.subplots(2, 1, sharex=True)                                            
    f,ax = plt.subplots()                                                                       
    r= d['row'].unique()                                                                        
    (c1, c2, c3, c4, c5) = sns.color_palette("husl", 6)[:5]                                     
    g = sns.FacetGrid(d, col='col', row='row',size=.7, aspect=5, palette="husl",margin_titles=True)
    g.map(sns.rugplot,'val',height=.12)                                                         
    print sns.axes_style()

despine does not remove the values

 sns.despine(left='False')                                                                   
    g.fig.subplots_adjust(wspace=.1, hspace=.02);                                               
    g.set_axis_labels(['a','b','c'], 'values');


    ax = plt.gcf().axes
    ax.axes.get_yaxis().set_visible(False)

    ax.set_visible(False)
    plt.show()

plt.gcf().axes give AttributeError: 'list' object has no attribute 'axes'

get_yaxis() does nothing.

How to remove yaxis values from FacetGrid in seaborn?

like image 729
syntax Avatar asked Jun 30 '14 19:06

syntax


1 Answers

Try calling g.set(yticks=[]) after you plot. This just loops through the axes and calls ax.set_yticks([]) on each of them.

This will also turn off the ticks/grid lines, which I assume you want for this plot, but if you just want to turn the labels off you can do g.set(yticklabels=[]).

like image 90
mwaskom Avatar answered Oct 17 '22 21:10

mwaskom