March 2014
Beginner to intermediate
222 pages
4h 7m
English
When creating figures for black and white documents, we are limited to gray levels. In practice, three levels of gray are usually the most we can reasonably use. However, using different line patterns allows some diversity. In this recipe, we are going to see how to control line pattern and thickness.
As in the case of colors, the line style is controlled by an optional parameter of pyplot.plot()as shown in the following script:
import numpy as np import matplotlib.pyplot as plt def pdf(X, mu, sigma): a = 1. / (sigma * np.sqrt(2. * np.pi)) b = -1. / (2. * sigma ** 2) return a * np.exp(b * (X - mu) ** 2) X = np.linspace(-6, 6, 1024) plt.plot(X, pdf(X, 0., 1.), color = 'k', linestyle = 'solid') ...
Read now
Unlock full access