Python-3.4.3/C2/Plotting-Data/English-timed
|
|
00:01 | Hello Friends. Welcome to the tutorial on "Plotting data ". |
00:06 | In this tutorial, we will learn about
Define a list of numbers. |
00:12 | Perform element-wise squaring of the list. |
00:16 | Plot data points.
and Plot errorbars. |
00:21 | To record this tutorial, I am using
Ubuntu Linux 14.04 operating system |
00:29 | Python 3.4.3
IPython 5.1.0 |
00:36 | To practise this tutorial, you should know how to
run basic Python commands on the ipython console |
00:44 | Use Plots interactively |
00:47 | Embellish a plot
. If not, see the relevant Python tutorials on this website. |
00:56 | Let us first open the Terminal by pressing Ctrl+Alt+T keys simultaneously.
Now, type ipython3 and press Enter. |
01:10 | Let us initialise the pylab package.
Type %pylab and press Enter. |
01:20 | Let us see an example for plotting the data related to a Simple Pendulum. |
01:26 | For a simple pendulum L is directly proportional to the square of time T.
We will be plotting L and T square values. |
01:38 | Let us use the data shown here for plotting. |
01:43 | First let us initiate 'l' and 't' values. |
01:48 | We initiate them as sequence of values. This is also called as List. |
01:56 | Type l equal to within square brackets values and press Enter |
02:06 | t equal to within square brackets the values and press Enter |
02:15 | Now we will obtain square of t by using function square. |
02:21 | Type tsquare=square within parentheses t and press Enter |
02:33 | Now type tsquare and press Enter |
02:39 | We see the values of array tsquare |
02:44 | Now to plot L versus T square, we will simply type
plot within parentheses l comma tsquare comma within single quotes dot and press Enter |
03:01 | We see the required plot. |
03:05 | You can also specify 'o' for filled circles. |
03:10 | For this let us clear the plot first.
Type clf parentheses Enter |
03:20 | So the plot is clear now. |
03:24 | Now type,
plot within parentheses l comma tsquare comma within single quotes o and press Enter |
03:36 | We see the plot with filled circles. |
03:40 | Pause the video. Try this exercise and then resume the video.
Plot the given experimental data with large dots. The data is on your screen. |
03:55 | Use the error data given here for plotting. |
03:59 | We shall again initialize the sequence values in the same manner as we did for l and t. |
04:07 | So, type delta underscore l equal to within square bracket the values and press Enter |
04:20 | delta underscore t within square bracket the values and press Enter |
04:29 | Now to plot L versus T square with an error bar, we use the function errorbar(). |
04:37 | So type, errorbar within parentheses l comma tsquare comma xerr equalto delta underscore l comma y underscore err equalto delta underscore t comma fmt equal to within single quotes bo
and press Enter |
05:08 | We see the plot L versus T square with an error bar. |
05:14 | You can explore other options of errorbar using the documentation of errorbar.
That is, errorbar question mark |
05:27 | Pause the video. Try this exercise and then resume the video. |
05:33 |
Plot the given experimental data with small dots. Also include the error in your plot. |
05:42 | Use the data given here for plotting. |
05:47 | This brings us to the end of this tutorial. In this tutorial, we have learned to,
Declare a list of numbers using the function array. |
05:59 | Perform element-wise squaring using the square function. |
06:04 | Use various options available for plotting like dots, lines etc. |
06:11 | Plot experimental data such that we can also represent error by using the errorbar() function. |
06:20 | Here are some self assessment questions for you to solve. |
06:25 | Square the following sequence distance underscore values equal to within square brackets 2.1 comma 4.6 comma 8.72 comma 9.03 |
06:39 | Plot L versus T in red pluses. |
06:44 | And the answers,
To square a sequence of values, we use the function square. |
06:51 | So square within parentheses distance underscore values |
06:57 | Answer to the second question
We pass an additional argument stating the desired parameter |
07:04 | So plot within parentheses L comma T comma within single quotes r plus for red pluses |
07:16 | Please post your timed queries in this forum. |
07:21 | Please post your general queries on Python in this forum. |
07:27 | FOSSEE team coordinates the TBC project. |
07:31 | Spoken-tutorial is funded by NMEICT, MHRD, Govt. of India.
For more details, visit this website. |
07:42 | This is from IIT Bombay signing off.
Thank You |