2014-10-01 75 views
7

當使用Seaborn facetGrid圖時。是否可以將行變量標籤設置爲左側(例如,作爲兩行子圖的第一行y軸標籤)?Python seaborn facetGrid:是否可以將行分類標籤位置設置爲左側

默認位置在頂部作爲子圖標題的一部分。不幸的是,合併後的文本有時會過長,無法合理地融入這個擁擠的空間。然後,我嘗試在實例化facetGrid對象時使用margin_titles = True選項。但是在這種情況下,行變量標籤位於圖例右側外側,可能離圖表太離譜。要顯示

  1. 移動圖例內緣冠軍時,margin_titles = Truelegend_out=True
  2. 允許行變量標籤:

    所以可以簡單的方法來改善我的兩個美分值得思考的審美在y軸標籤的左邊。

  3. 其他想法?

對不起,沒有積累足夠的分數可以添加圖表示例。

回答

2

當然可以!枚舉在軸上似乎工作得很好。

import seaborn as sns 
import matplotlib.pyplot as plt 
sns.set(style='ticks', color_codes=True) 

tips = sns.load_dataset('tips') 

g = sns.FacetGrid(tips, col='time', row='sex') 
g = g.map(plt.scatter, 'total_bill', 'tip', edgecolor='w') 

for i, axes_row in enumerate(g.axes): 
    for j, axes_col in enumerate(axes_row): 
     row, col = axes_col.get_title().split('|') 

     if i == 0: 
      axes_col.set_title(col.strip()) 
     else: 
      axes_col.set_title('') 

     if j == 0: 
      ylabel = axes_col.get_ylabel() 
      axes_col.set_ylabel(row.strip() + ' | ' + ylabel) 

plt.show() 

enter image description here

相關問題