How to set font size of Matplotlib axis Legend?

后端 未结 7 1617
渐次进展
渐次进展 2020-12-02 10:19

I have a code like this:

import matplotlib.pyplot as plt
from matplotlib.pyplot import *
from matplotlib.font_manager import FontProperties

fontP = FontProp         


        
7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 10:54

    Here is how to change the fontsize of the legend list and/or legend title:

    legend=plt.legend(list,loc=(1.05,0.05), title=r'$\bf{Title}$') #Legend: list, location, Title (in bold)
    legend.get_title().set_fontsize('6') #legend 'Title' fontsize
    plt.setp(plt.gca().get_legend().get_texts(), fontsize='12') #legend 'list' fontsize
    

提交回复
热议问题