...

Library - Matplotlib

Back to Course

Lesson Description


Lession - #505 matplotlib Line


How would I plot a line in matplotlib?

To plot a line plot in Matplotlib, you utilize the nonexclusive plot(>
work from the PyPlot occurrence. There's no particular lineplot(>
work - the conventional one naturally plots utilizing lines or markers. This outcomes in much a similar line plot as in the past, as the upsides of x are gathered.

Example

Use a dotted line:

import matplotlib.pyplot as plt
import numpy as np

ypoints = np.array([3, 8, 1, 10]>
plt.plot(ypoints, linestyle = 'dotted'>
plt.show(>


Curved line
The plot(>
strategy additionally works for different sorts of line diagrams. It needn't bother with to be a straight line, y can have any sort of values.


import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(-1, 1, 50>
y = 2**x + 1 plt.plot(x, y>
plt.show(>