August 2017
Beginner to intermediate
334 pages
8h 22m
English
The size, style, fontweight, family, and variant parameters can be set under font. They can be set as keyword arguments directly in a text command:
plt.xlabel('xlabel',size=20,fontweight='semibold',family='serif',style='italic')
Or they can be stored and passed as a dictionary with keys of parameter names in strings and their corresponding values:
import matplotlib.pyplot as pltfontparams = {'size':16,'fontweight':'light', 'family':'monospace','style':'normal'}x = [1,2,3]y = [2,4,6]plt.plot(x,y)plt.xlabel('xlabel',size=20,fontweight='semibold',family='serif',style='italic')plt.ylabel('ylabel',fontparams)plt.show()
The preceding code sets different font families, sizes, weight, and style for the axis labels. You may experiment ...
Read now
Unlock full access