In [2]:
from matplotlib import pyplot as plt
%matplotlib inline
In [9]:
plt.plot([5,6,7,8],[7,4,8,4])
## Adding labels
plt.title("Random Plot")
plt.xlabel("$1/2\cdot x$")
plt.ylabel("Dispersion $[m]$")
Out[9]:
In [11]:
# import the styles
from matplotlib import style
# select the 'ggplot' style from the default ones
style.use('ggplot')
# and make the same plot -- pretty cool heh? :)
plt.plot([5,6,7,8],[7,4,8,4])
plt.title("Random Plot")
plt.xlabel("$1/2\cdot x$")
plt.ylabel("Dispersion $[m]$")
Out[11]:
We can also use some of the formatting options in the plot command. For example color, width, label, etc.
In [20]:
# add 2 plots on the same canvas
plt.plot([2,3,4],[4,9,16], color='green', label="$x^2", lw=2)
plt.plot([2,3,4],[8,27,64], color='red', label="$x^3", lw=3)
# add the legend:
plt.legend()
# add grid
plt.grid(True, color='blue')
In [ ]: