In [91]:
# add:  i) title    ii) legend  iii) labels
# use Latex to format the title and ...

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

x = np.linspace(-6,6, 100)

y = np.power(x,2)
plt.title("Parabola: $x=y^2$", fontsize="16")  # add a title to the figure. Writing equation in latex format
plt.xlabel("x axis")            # add x label
plt.ylabel("y label")           # add y label
plt.plot(x, y, 
         label="$y=x^2$")  # a label to be shown in the legend
plt.legend( loc='best',
           # loc="upper right" , "lower right","right" ,..., "upper center", "lower cener", "center"
           fancybox=True, 
           shadow=True, 
          title="legned title")   # show the legend, and locate it in the best position according to matplotlib
plt.show()
In [21]:
# add text to the graph

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

x = np.linspace(0,6, 100)

y = np.power(x,2)
plt.text(2.3, 10, '$y=x^2$', fontsize=15, color='r')   #plt.text(x coord., y coord., "the text", extra decorations)       
plt.plot(x, y)
plt.show()
In [36]:
# add a box to the text 
import numpy as np 
import matplotlib.pyplot as plt
%matplotlib inline

x = np.linspace(0,6, 100)

y = np.power(x,2)

box = {'facecolor': '0.65', 
       'edgecolor': 'k', 
       'boxstyle' :'round', 
       "alpha" :0.2}   # add transparency to the box (the text is not effected)

plt.text(2, 12, '$y=x^2$', fontsize=15, bbox =box )  # surround the text with a box
plt.plot(x, y)
plt.show()
In [82]:
# draw arrows 
import numpy as np 
import matplotlib.pyplot as plt
%matplotlib inline

x = np.linspace(0,6, 100)

y = np.power(x,2)

plt.annotate('$y=x^2$',
             xytext = (2,18),  # text location
             xy=(3,10),        # arrows points to 
             ha = 'left',    # horizontal alignment 
             va = 'bottom',    # vertical alignment
             arrowprops={'facecolor': 'k', 'shrink' : 0.01}, 
            )
plt.plot(x, y)
plt.show()
In [103]:
# add gride
import numpy as np 
import matplotlib.pyplot as plt
%matplotlib inline

x = np.linspace(0,6, 100)

y = np.power(x,2)

plt.plot(x, y)
plt.grid(True, 
       # lw = 1, # linewidth
       # ls = '--', # linestyle
       # c = '0.8' # color 
         )
plt.show()