1212functions in a custom module that set the defaults, e.g.,::
1313
1414 def set_pub():
15- rc('font', weight='bold') # bold fonts are easier to see
16- rc('tick', labelsize=15) # tick labels bigger
17- rc('lines', lw=1, color='k') # thicker black lines
18- rc('grid', c='0.5', ls='-', lw=0.5) # solid gray grid lines
19- rc('savefig', dpi=300) # higher res outputs
15+ rcParams.update({
16+ "font.weight": "bold", # bold fonts
17+ "tick.labelsize": 15, # large tick labels
18+ "lines.linewidth": 1, # thick lines
19+ "lines.color": "k", # black lines
20+ "grid.color": "0.5", # gray gridlines
21+ "grid.linestyle": "-", # solid gridlines
22+ "grid.linewidth": 0.5, # thin gridlines
23+ "savefig.dpi": 300, # higher resolution output.
24+ })
2025
2126Then as you are working interactively, you just need to do::
2227
@@ -33,15 +38,18 @@ def set_pub():
3338plt .plot ([1 , 2 , 3 ])
3439
3540# the axes attributes need to be set before the call to subplot
36- plt .rc ('font' , weight = 'bold' )
37- plt .rc ('xtick.major' , size = 5 , pad = 7 )
38- plt .rc ('xtick' , labelsize = 15 )
39-
40- # using aliases for color, linestyle and linewidth; gray, solid, thick
41- plt .rc ('grid' , c = '0.5' , ls = '-' , lw = 5 )
42- plt .rc ('lines' , lw = 2 , color = 'g' )
41+ plt .rcParams .update ({
42+ "font.weight" : "bold" ,
43+ "xtick.major.size" : 5 ,
44+ "xtick.major.pad" : 7 ,
45+ "xtick.labelsize" : 15 ,
46+ "grid.color" : "0.5" ,
47+ "grid.linestyle" : "-" ,
48+ "grid.linewidth" : 5 ,
49+ "lines.linewidth" : 2 ,
50+ "lines.color" : "g" ,
51+ })
4352plt .subplot (312 )
44-
4553plt .plot ([1 , 2 , 3 ])
4654plt .grid (True )
4755
0 commit comments