Pour changer la taille de la police dans une légende sous matplotlib il suffit d'ajouter le mot clé "prop" (i.e. plt.legend(prop={'size':12}) dans la fonction pyplot: legend comme dans cette exemple
from numpy import *
import matplotlib.pyplot as plt
plt.figure()
c2 = array([ 0. , 0. , 0. , 0. , 0. ,
0.00071727, 0.0009723 , 0.00130702, 0.00132296, 0.00180114,
0.00202429, 0.00226338, 0.00269374, 0.00277344, 0.00285314,
0.0037298 , 0.00416016, 0.0050687 , 0.00616851, 0.00672639,
0.00820874, 0.01036055, 0.01110969, 0.0113966 , 0.01480761,
0.01581179, 0.01732602, 0.01949377, 0.02344671, 0.02677803,
0.02827632, 0.03030062, 0.03163952, 0.02999777, 0.02719245,
0.02523192, 0.02264975, 0.02013134, 0.0196691 , 0.01745354,
0.01526985, 0.01283114, 0.01099812, 0.01036055, 0.00911728,
0.00820874, 0.00776244, 0.00680608, 0.00564251, 0.0054353 ,
0.00476585, 0.00420798, 0.00393701, 0.00329944, 0.00277344,
0.00259811, 0.00219962, 0.00189678, 0.00192866, 0.00143454])
c5 = array([ 0. , 0. , 0. , 0. , 0. ,
0.02591731, 0.02910517, 0.0321177 , 0.03275527, 0.03068316,
0.026523 , 0.02266569, 0.01906341, 0.01560458, 0.01456852,
0.01440913, 0.01397877, 0.01377156, 0.01203417, 0.01099812,
0.0101374 , 0.01032867, 0.00881443, 0.00781026, 0.00793777,
0.00694954, 0.00612069, 0.00489337, 0.00508464, 0.00428767,
0.00395295, 0.00344289, 0.00310816, 0.00301253, 0.00210399,
0.00188084, 0.00172144, 0.00168957, 0.00108387, 0.0014186 ,
0.00113169, 0.00100418, 0.0009723 , 0.00082884, 0.00070133,
0.00087666, 0.00060569, 0.00078103, 0.00078103, 0.00066945,
0.0003666 , 0.000526 , 0.00055788, 0.0004463 , 0.00046224,
0.00051006, 0.00039848, 0.00027097, 0.00054194, 0.00025503])
left = arange(0,60,1)
bar1 = plt.bar(left, c2, width=0.5, bottom=0, color=(0.65098041296005249, 0.80784314870834351, 0.89019608497619629, 1.0), label='CALIOP: Ice')
bar2 = plt.bar(left+0.5, c5, width=0.5, bottom=0, color=(0.69411766529083252, 0.3490196168422699, 0.15686275064945221, 1.0), label='CALIOP: Liquid')
plt.xlabel(r'Forced Ice Re at $2.1\mu m$')
plt.ylabel("Probability Distribution")
plt.legend()
plt.savefig('LegendFontSize1.png')
Recherches associées
Liens | Site |
---|---|
How to change legend size with matplotlib.pyplot | stackoverflow |
pyplot legend | matplotlib doc |