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: shared_axis_demo.py

Next topic

pylab_examples example code: simple_plot_fps.py

This Page

pylab_examples example code: simple_plot.pyΒΆ

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

../../_images/simple_plot.png
import matplotlib.pyplot as plt
import numpy as np

t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)
plt.plot(t, s)

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

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