2017-07-20 7 views
1

のデフォルトのスタイルを変更する:今すぐ私は、各プロットタスクのために呼び出されるggplotのデフォルトのスタイルを変更するには、次の装飾的な機能を書いたggplot

# Style plots (decorator) 
def plot_styling(func): 
    def wrapper(*args, **kwargs): 
     style = {'axes.titlesize' : 24, 
       'axes.labelsize' : 20, 
       'lines.linewidth' : 3, 
       'lines.markersize' : 10, 
       'xtick.labelsize' : 16, 
       'ytick.labelsize' : 16, 
       } 
     with plt.style.context((style)): 
      ax = func(*args, **kwargs)  
    return wrapper 

、私はライトグレーからデフォルトのグリッドの色を変更したいです白、グリッド線はグレーになります。私はこれについてどうやって行くのですか?

  • panel.background
  • panel.grid.major
  • panel.grid.minor

あり、参照は、私たちを意味しますhereは、あなたがそれはあなたが望むものを達成するであろう変更することができますが、次のされている参考文献を見ている

答えて

1

これらの属性の値をから返された値に割り当てます機能。

panel.background = element_rect(fill = "white", colour = "grey50") Image from reference documents to set the background of a grid to white

あなたのデコレータを変更するには、私はstyle辞書にこれらを追加します。

# Style plots (decorator) 
def plot_styling(func): 
    def wrapper(*args, **kwargs): 
     style = {'axes.titlesize': 24, 
       'axes.labelsize': 20, 
       'lines.linewidth': 3, 
       'lines.markersize': 10, 
       'xtick.labelsize': 16, 
       'ytick.labelsize': 16, 
       'panel.background': element_rect(fill="white"), 
       'panel.grid.major': element_line(colour="grey50"), 
       'panel.grid.minor': element_line(colour="grey50") 
       } 
     with plt.style.context((style)): 
      ax = func(*args, **kwargs)  
    return wrapper 
関連する問題