Fine control over the font size in Seaborn plots for academic papers

后端 未结 2 598
故里飘歌
故里飘歌 2021-01-30 07:17

I\'m currently trying to use Seaborn to create plots for my academic papers. The plots look great and easy to generate, but one problem that I\'m having some trouble with is hav

2条回答
  •  不思量自难忘°
    2021-01-30 07:42

    It is all but satisfying, isn't it? The easiest way I have found to specify when setting the context, e.g.:

    sns.set_context("paper", rc={"font.size":8,"axes.titlesize":8,"axes.labelsize":5})   
    

    This should take care of 90% of standard plotting usage. If you want ticklabels smaller than axes labels, set the 'axes.labelsize' to the smaller (ticklabel) value and specify axis labels (or other custom elements) manually, e.g.:

    axs.set_ylabel('mylabel',size=6)
    

    you could define it as a function and load it in your scripts so you don't have to remember your standard numbers, or call it every time.

    def set_pubfig:
        sns.set_context("paper", rc={"font.size":8,"axes.titlesize":8,"axes.labelsize":5})   
    

    Of course you can use configuration files, but I guess the whole idea is to have a simple, straightforward method, which is why the above works well.

    Note: If you specify these numbers, specifying font_scale in sns.set_context is ignored for all specified font elements, even if you set it.

提交回复
热议问题