|
| 1 | +""" |
| 2 | +I'm not trying to make a good liking figure here, but just to show |
| 3 | +some examples of customizing rc params on the fly |
| 4 | +
|
| 5 | +If you like to work interactively, and need to create different sets |
| 6 | +of defaults for figures (eg one set of defaults for publication, one |
| 7 | +set for interactive exmplotation, you may want to define some |
| 8 | +functions in a custom module that set the defaults, eg |
| 9 | +
|
| 10 | +def set_pub(): |
| 11 | + rc('font', weight='bold') # bold fonts are easier to see |
| 12 | + rc('tick', labelsize=15) # tick labels bigger |
| 13 | + rc('lines', lw=1, color='k') # thicker black lines (no budget for color!) |
| 14 | + rc('grid', c=0.5, ls='-', lw=0.5) # solid gray grid lines |
| 15 | + rc('savefig', dpi=300) # higher res outputs |
| 16 | +
|
| 17 | +
|
| 18 | + |
| 19 | +Then as you are working interactively, you just need to do |
| 20 | +
|
| 21 | +>>> set_pub() |
| 22 | +>>> subplot(111) |
| 23 | +>>> plot([1,2,3]) |
| 24 | +>>> savefig('myfig') |
| 25 | +>>> rcdefaults() # restore the defaults |
| 26 | +
|
| 27 | +""" |
| 28 | +from matplotlib.matlab import * |
| 29 | + |
| 30 | +subplot(311) |
| 31 | +plot([1,2,3]) |
| 32 | + |
| 33 | +# the axes attributes need to be set before the call to subplot |
| 34 | +rc('font', weight='bold') |
| 35 | +rc('tick.major', size=5, pad=7) |
| 36 | +rc('tick', labelsize=15) |
| 37 | + |
| 38 | +# using aliases for color, linestyle and linewith; gray, solid, thick |
| 39 | +rc('grid', c=0.5, ls='-', lw=5) |
| 40 | + |
| 41 | +subplot(312) |
| 42 | +rc('lines', lw=2, color='g') |
| 43 | +plot([1,2,3]) |
| 44 | +grid(True) |
| 45 | + |
| 46 | +rcdefaults() |
| 47 | +subplot(313) |
| 48 | +plot([1,2,3]) |
| 49 | +grid(True) |
| 50 | +show() |
0 commit comments