You are on page 1of 1

Chapter 11.

Plotting and More About Classes


Its also possible to change the type size and line width used in plots. This can be
done using keyword arguments in individual calls to functions, e.g., the code
principal = 10000 #initial investment
interestRate = 0.05
years = 20
values = []
for i in range(years + 1):
values.append(principal)
principal += principal*interestRate
pylab.plot(values, linewidth = 30)
pylab.title('5% Growth, Compounded Annually',
fontsize = 'xx-large')
pylab.xlabel('Years of Compounding', fontsize = 'x-small')
pylab.ylabel('Value of Principal ($)')

produces the intentionally bizarre-looking plot

It is also possible to change the default values, which are known as rc settings.
(The name rc is derived from the .rc file extension used for runtime
configuration files in Unix.) These values are stored in a dictionary-like variable
that can be accessed via the name pylab.rcParams. So, for example, you can set
the default line width to 6 points61 by executing the code
pylab.rcParams['lines.linewidth'] = 6.

61 The point is a measure used in typography. It is equal to 1/72 of an inch, which is


0.3527mm.

145

You might also like