Plotting Graphs

One of the mostly widely used methods of the Subplot class is the plot() function. It is used to draw lines or markers on the Subplot (or Axes). Listing 11-1 demonstrates how to draw a sine function graph.

Listing 11-1. Drawing a Simple Graph import matplotlib.pyplot as plt import numpy as np fig = plt.figure()


If you run this script on a system with an X window manager running, you will see a graph plotted in a separate window, as shown in Figure 11 -4. You'll be able to use the window functions such as panning and zooming, as well as save and print the file.

MOO_Figure 1_






20 40 60 80 100

^OO-f ffi a

Figure 11-4. An example of matplotlib window instance

0 0

Post a comment