In this example, we show a few plotting customization options.
We can easily specify the color and line style of each plot.
%pylab inline
Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline]. For more information, type 'help(pylab)'.
x = linspace(-10, 10, 1000)
plot(x, sin(x), '-r')
plot(x, cos(x), '--g')
[<matplotlib.lines.Line2D at 0x58319d0>]
Here are a few other customization options:
plot(x, sin(x), '-r', label='sine')
plot(x, cos(x), '--g', label='cosine')
xticks([-10, 0, 10])
yticks([-1, 0, 1])
ylim(-2, 2)
legend()
grid()
We can plot Cartesian and polar plots side by side.
x = linspace(0, 2 * pi, 1000)
y = 1 + 2 * cos(5 * x)
subplot(121)
plot(x, y)
subplot(122, polar=True)
polar(x, y)
[<matplotlib.lines.Line2D at 0x5b6f2d0>]