【问题标题】:remove yaxis values from FacetGrid in seaborn从 seaborn 中的 FacetGrid 中删除 yaxis 值
【发布时间】:2014-08-21 05:46:25
【问题描述】:

正在尝试删除 y 轴值。

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

试图抓图不行。

    #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 不会删除值

 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().axesAttributeError: 'list' object has no attribute 'axes'

get_yaxis() 什么都不做。

如何从 seaborn 中的 FacetGrid 中删除 yaxis 值?

【问题讨论】:

    标签: matplotlib seaborn


    【解决方案1】:

    在你绘制之后尝试调用g.set(yticks=[])。这只是遍历轴并在每个轴上调用ax.set_yticks([])

    这也将关闭刻度线/网格线,我假设你想要这个情节,但如果你只是想关闭标签,你可以做g.set(yticklabels=[])

    【讨论】:

    • 感谢您的帮助!我也想帮助扩展你的好 api 的解释;例如 set() 函数,以及更多内容。我非常感激,但不得不问一些关于事情如何运作的基本问题的基本问题。当我完成这个项目时,也许我可以更完整地阅读您的 src 而不是公开/扩展您的 api ,而是帮助那些刚接触 matplotlib 的人......再次感谢您!!!
    • 它已被记录在 here,但是是的,FacetGrid 很复杂,你必须了解很多关于它的信息,充分利用它。
    猜你喜欢
    • 2020-12-30
    • 1970-01-01
    • 2022-01-28
    • 2020-05-30
    • 2021-02-06
    • 2018-02-25
    • 1970-01-01
    • 2019-01-23
    • 1970-01-01
    相关资源
    最近更新 更多