day1/session2.tex
changeset 397 28915381ac32
parent 392 534803f1ca11
child 408 217c38c06ebd
equal deleted inserted replaced
396:502d4d151fa2 397:28915381ac32
   127 \begin{frame}[fragile]
   127 \begin{frame}[fragile]
   128 \frametitle{Why would I plot f(x)?}
   128 \frametitle{Why would I plot f(x)?}
   129 Do we plot analytical functions or experimental data?
   129 Do we plot analytical functions or experimental data?
   130 \begin{small}
   130 \begin{small}
   131 \begin{lstlisting}
   131 \begin{lstlisting}
   132 In []: x = [0, 1, 2, 3]
   132 In []: time = [0, 1, 2, 3]
   133 
   133 
   134 In []: y = [7, 11, 15, 19]
   134 In []: distance = [7, 11, 15, 19]
   135 
   135 
   136 In []: plot(x, y)
   136 In []: plot(time,distance)
   137 Out[]: [<matplotlib.lines.Line2D object at 0xa73aa8c>]
   137 Out[]: [<matplotlib.lines.Line2D object at 0xa73aa8c>]
   138 
   138 
   139 In []: xlabel('X')
   139 In []: xlabel('time')
   140 Out[]: <matplotlib.text.Text object at 0x986e9ac>
   140 Out[]: <matplotlib.text.Text object at 0x986e9ac>
   141 
   141 
   142 In []: ylabel('Y')
   142 In []: ylabel('distance')
   143 Out[]: <matplotlib.text.Text object at 0x98746ec>
   143 Out[]: <matplotlib.text.Text object at 0x98746ec>
   144 \end{lstlisting}
   144 \end{lstlisting}
   145 \end{small}
   145 \end{small}
   146 \end{frame}
   146 \end{frame}
   147 
   147 
   158 \item What if we want to plot the points!
   158 \item What if we want to plot the points!
   159 \end{itemize}
   159 \end{itemize}
   160 \begin{lstlisting}
   160 \begin{lstlisting}
   161   In []: clf()
   161   In []: clf()
   162 
   162 
   163   In []: plot(x, y, 'o')
   163   In []: plot(time, distance, 'o')
   164   Out[]: [<matplotlib.lines.Line2D object at 0xac17e0c>]
   164   Out[]: [<matplotlib.lines.Line2D object at 0xac17e0c>]
   165 
   165 
   166   In []: clf()
   166   In []: clf()
   167   In []: plot(x, y, '.')
   167   In []: plot(time, distance, '.')
   168   Out[]: [<matplotlib.lines.Line2D object at 0xac17e0c>]
   168   Out[]: [<matplotlib.lines.Line2D object at 0xac17e0c>]
   169 \end{lstlisting}
   169 \end{lstlisting}
   170 \end{frame}
   170 \end{frame}
   171 
   171 
   172 \begin{frame}[fragile]
   172 \begin{frame}[fragile]
   188 
   188 
   189 \section{Lists}
   189 \section{Lists}
   190 \begin{frame}[fragile]
   190 \begin{frame}[fragile]
   191   \frametitle{Lists: Introduction}
   191   \frametitle{Lists: Introduction}
   192   \begin{lstlisting}
   192   \begin{lstlisting}
   193     In []: x = [0, 1, 2, 3]
   193     In []: time = [0, 1, 2, 3]
   194 
   194 
   195     In []: y = [7, 11, 15, 19]
   195     In []: distance = [7, 11, 15, 19]
   196 
   196 
   197   \end{lstlisting}
   197   \end{lstlisting}
   198 What are \typ{x} and \typ{y}?\\
   198 What are \typ{x} and \typ{y}?\\
   199 \begin{center}
   199 \begin{center}
   200 \alert{\typ{lists!!}}
   200 \alert{\typ{lists!!}}
   361 \end{frame}
   361 \end{frame}
   362 
   362 
   363 \begin{frame}[fragile]
   363 \begin{frame}[fragile]
   364 \frametitle{Plotting from \typ{pendulum.txt}}
   364 \frametitle{Plotting from \typ{pendulum.txt}}
   365 Open a new script\\
   365 Open a new script\\
   366 Save as \typ{pendulum.py} after typing first line
   366 Save as \typ{pendulum_plot.py} after typing first line
   367 \begin{lstlisting}
   367 \begin{lstlisting}
   368 L = []
   368 L = []
   369 t = []
   369 t = []
   370 for line in open('pendulum.txt'):
   370 for line in open('pendulum.txt'):
   371     point = line.split()
   371     point = line.split()