Version 3.0.2
matplotlib

Table of Contents

Related Topics

Simple Plot

Create a simple plot.

===========
Simple Plot
===========

Create a simple plot.
"""

import matplotlib
import matplotlib.pyplot as plt
import numpy as np

# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)

fig, ax = plt.subplots()
ax.plot(t, s)

ax.set(xlabel='time (s)', ylabel='voltage (mV)',
       title='About as simple as it gets, folks')
ax.grid()

fig.savefig("test.png")
plt.show()
Traceback (most recent call last):
  File "/build/matplotlib-xz4j8t/matplotlib-3.1.2/examples/lines_bars_and_markers/simple_plot.py", line 1
    ===========
    ^
SyntaxError: invalid syntax

References

The use of the following functions and methods is shown in this example:

matplotlib.axes.Axes.plot
matplotlib.pyplot.plot
matplotlib.pyplot.subplots
matplotlib.figure.Figure.savefig

Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery