0% found this document useful (0 votes)
134 views1 page

Introduction To Computation and Programming Using Python, Revised - Guttag, John v..162

This document discusses customizing plots in Python by changing the type size, line width, and default values. It provides an example of how to specify linewidth and fontsize arguments in individual plotting function calls to produce an intentionally unusual plot. It also explains that default values, known as rc settings, can be changed by modifying the rcParams dictionary, giving an example of how to set the default linewidth to 6 points.

Uploaded by

ZhichaoWang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
134 views1 page

Introduction To Computation and Programming Using Python, Revised - Guttag, John v..162

This document discusses customizing plots in Python by changing the type size, line width, and default values. It provides an example of how to specify linewidth and fontsize arguments in individual plotting function calls to produce an intentionally unusual plot. It also explains that default values, known as rc settings, can be changed by modifying the rcParams dictionary, giving an example of how to set the default linewidth to 6 points.

Uploaded by

ZhichaoWang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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