You are reading an old version of the documentation (v1.5.0). For the latest version see https://matplotlib.org/stable/

We're updating the default styles for Matplotlib 2.0

Learn what to expect in the new updates

matplotlib

Previous topic

pylab_examples example code: simple_plot.py

Next topic

pylab_examples example code: specgram_demo.py

This Page

pylab_examples example code: simple_plot_fps.pyΒΆ

(Source code, png, hires.png, pdf)

../../_images/simple_plot_fps.png
"""
Example: simple line plot.
Show how to make and save a simple line plot with labels, title and grid
"""
from __future__ import print_function  # not necessary in Python 3.x
import matplotlib.pyplot as plt
import numpy as np
import time


plt.ion()

t = np.arange(0.0, 1.0 + 0.001, 0.001)
s = np.cos(2*2*np.pi*t)
plt.plot(t, s, '-', lw=2)

plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
plt.title('About as simple as it gets, folks')
plt.grid(True)

frames = 100.0
t = time.time()
c = time.clock()
for i in range(int(frames)):
    part = i / frames
    plt.axis([0.0, 1.0 - part, -1.0 + part, 1.0 - part])
wallclock = time.time() - t
user = time.clock() - c
print("wallclock:", wallclock)
print("user:", user)
print("fps:", frames / wallclock)

Keywords: python, matplotlib, pylab, example, codex (see Search examples)