day1/cheatsheet1.tex
changeset 276 4555c3814dd4
parent 264 c3a1de5b8216
child 295 39d7c4e14585
equal deleted inserted replaced
275:71e50184d482 276:4555c3814dd4
     1 \documentclass[12pt]{article}
     1 \documentclass[12pt]{article}
     2 \title{Interactive Plotting}
     2 \title{Interactive Plotting}
     3 \author{FOSSEE}
     3 \author{FOSSEE}
     4 \begin{document}
     4 \begin{document}
     5 \maketitle
     5 \date{}
       
     6 \vspace{-1in}
       
     7 \begin{center}
       
     8 \LARGE{Interactive Plotting}\\
       
     9 \large{FOSSEE}
       
    10 \end{center}
       
    11 \section{Starting up...}
     6 
    12 
     7 \section{Starting up...}
       
     8 \begin{verbatim}
    13 \begin{verbatim}
     9   $ ipython -pylab  
    14   $ ipython -pylab  
    10 \end{verbatim}
    15 \end{verbatim}
    11 Exiting Ipython
    16 Exiting 
    12 \begin{verbatim}     
    17 \begin{verbatim}     
    13   In [1]: print "Hello, World!"
    18 In [2]: (Ctrl-D)^D
    14   In [2]: ^D
    19 Do you really want to exit ([y]/n)? y
    15   Do you really want to exit ([y]/n)? y
       
    16 \end{verbatim}
    20 \end{verbatim}
    17 Breaking out of loops
    21 Breaking out of loops
    18 \begin{verbatim}     
    22 \begin{verbatim}     
    19   In [1]: while True:
    23 In [1]: while True:
    20     ...:     print "Hello, World!"
    24    ...:     print "Hello, World!"
    21     ...:     
    25    ...:     
    22   Hello, World!
    26 Hello, World!
    23   Hello, World!^C
    27 Hello, World!(Ctrl-C)^C
    24 \end{verbatim}
    28 \end{verbatim}
    25 
    29 
    26 \section{First Plot}
    30 \section{Plotting}
    27 \begin{verbatim}
    31 \begin{verbatim}
    28   In [2]: x=linspace(0, 2*pi, 50)
    32 In [1]: x = linspace(0, 2*pi, 50)
    29 
    33 In [2]: plot(x,sin(x))
    30   In [3]: plot(x,sin(x))
    34 In [3]: xlabel('x')
    31   Out[3]: [<matplotlib.lines.Line2D object at 0xb6e5874c>]
    35 In [4]: ylabel('sin(x)')
       
    36 In [5]: legend(['x', '-x', 'sin(x)', 'xsin(x)'])
       
    37 In [6]: annotate('origin', xy=(0, 0), xytext=(0, -7),
       
    38                  arrowprops=dict(shrink=0.05))
       
    39 In [7]: xlim(5*pi, 5*pi)
       
    40 In [8]: ylim(5*pi, 5*pi)
       
    41 In [9]: clf() #Clears the Plot area
    32 \end{verbatim}
    42 \end{verbatim}
    33 
       
    34 \section{Labeling}
       
    35 \begin{verbatim}
       
    36   In [4]: xlabel('x')
       
    37 
       
    38   In [5]: ylabel('sin(x)')
       
    39 \end{verbatim}
       
    40 
       
    41 \section{Another example}
       
    42 \begin{verbatim}
       
    43 In [6]: clf()
       
    44 
       
    45 In [7]: y = linspace(0,10,101)
       
    46 
       
    47 In [8]: plot(y, exp(-y))
       
    48 
       
    49 In [9]: xlabel('y')
       
    50 
       
    51 In [10]: ylabel(r'$e^{-y}$')
       
    52 \end{verbatim}
       
    53 
       
    54 \end{document}
    43 \end{document}
    55 
    44