<jupyter_start><jupyter_text>Matplotlib and Interact <NAME> <EMAIL> [Matplotlib](http://matplotlib.org/) is a python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms. Let's prepare some data:<jupyter_code>x = np.linspace(0,10,20)
y = x ** 2<jupyter_output><empty_output><jupyter_text>Plot is as easy as this:<jupyter_code>plt.plot(x,y);<jupyter_output><empty_output><jupyter_text>Line style and labels are controlled in a way similar to Matlab:<jupyter_code>plt.plot(x, y, 'r--o')
plt.xlabel('xxxxxx')
plt.ylabel('yyyyyy')
plt.title('title1000')<jupyter_output><empty_output><jupyter_text>You can plot several individual lines at once:<jupyter_code>plt.plot(x, y, 'r--o', x, y ** 1.1, 'bs', x, y ** 1.2, 'g^-' );<jupyter_output><empty_output><jupyter_text>Exercise- plot sine- plot sine abd cosine on one plot- make sine thicker (linewidth=5) and sine dashed [XKCD](http://xkcd.com/1064/) Alternatives- [Bokeh](http://bokeh.pydata.org/)- [plot.ly](http://plot.ly)- [ggplot](http://ggplot.yhathq.com/) Interact<jupyter_code>from IPython.html.widgets import *
def pl(f):
    x = np.linspace(0,10,20)
    plt.plot(x,np.sin(2*np.pi*x*f));
pl(61000)
interact(pl, f=(1,10,0.1));
def pltsin(f, a):
    x = np.linspace(0,10,2000)
    plt.plot(x,a*np.sin(2*np.pi*x*f))
    plt.ylim(-10,10)
pltsin(2,4)
interact(pltsin, f=(1,10,0.1), a=(1,10,1));<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup