Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Line Plots

The code below displays three line plots: linear (black solid line), quadratic (black dashed line), and cubic (black dotted line).

import matplotlib.pyplot as plt
from numpy import array
x_grid = array(range(1, 100)) / 30.0
plt.figure() # open a figure
plt.plot(x_grid, x_grid, "k-") # draws a solid line
plt.plot(x_grid, x_grid ** 2, "k--") # draws a dashed line
plt.plot(x_grid, x_grid ** 3, "k.") # draws a dotted line
plt.title("Linear, Quadratic, and Cubic Growth")
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content