1 00:00:01 --> 00:00:04 Hello Friends and Welcome to this tutorial on "Plotting Experimental data". 2 00:00:05 --> 00:00:17 At the end of this tutorial, you will be able to, Define a list of numbers. perform element wise squaring of the list. Plot data points. plot errorbars. 3 00:00:18 --> 00:00:22 One needs to be familiar with the concepts of plotting mathematical functions in Python. 4 00:00:23 --> 00:00:29 We will use data from a Simple Pendulum Experiment to illustrate. 5 00:00:30 --> 00:00:36 As we know for a simple pendulum, length L is directly proportional to the square of time T. 6 00:00:37 --> 00:00:39 We shall be plotting L and T square values. 7 00:00:40 --> 00:00:43 First we will have to initiate L and T values. 8 00:00:44 --> 00:00:46 We initiate them as sequence of values. 9 00:00:47 --> 00:00:51 We define a sequence by comma separated values inside two square brackets. 10 00:00:52 --> 00:00:53 This is also called a List. 11 00:00:54 --> 00:00:57 Let's create two sequences L and t. 12 00:00:58 --> 00:01:09 L = [0.1, 0.2, 0.3, 0.4, 0.5,0.6, 0.7, 0.8, 0.9] 13 00:01:10 --> 00:01:28 T= [0.69, 0.90, 1.19,1.30, 1.47, 1.58, 1.77, 1.83, 1.94] 14 00:01:29 --> 00:01:35 To obtain the square of sequence T we will use the function square with argument T. 15 00:01:36 --> 00:01:37 This is saved into the variable Tsquare. 16 00:01:38 --> 00:01:54 So type Tsquare=square withinbracket T 17 00:01:55 --> 00:01:59 Tsqaure enter 18 00:02:00 --> 00:02:06 Now to plot L versus T square, we will simply type 19 00:02:07 --> 00:02:20 plot within bracket L comma Tsquare comma within single quote dot 20 00:02:21 --> 00:02:25 Here single quote dot displays the plot in a dot pattern. 21 00:02:26 --> 00:02:30 You can also specify 'o' for big dots. 22 00:02:31 --> 00:02:33 For this let us clear the first plot . 23 00:02:34 --> 00:02:38 Type clf closing bracket and hit enter 24 00:02:39 --> 00:03:00 Then Type plot within bracket L comma Tsquare comma within single quote o hit enter now to clear the bracket type clf closing bracket 25 00:03:01 --> 00:03:02 Let us move further. 26 00:03:03 --> 00:03:09 For any experimental there is always an error in measurements due to instrumental and human constraints. 27 00:03:10 --> 00:03:16 Now we shall try and take these errors into account in our plots . 28 00:03:17 --> 00:03:20 Pause the video here, try out the following exercise and resume the video. 29 00:03:21 --> 00:03:24 Plot the given experimental data with large dots. 30 00:03:25 --> 00:03:28 The data is on your screen. 31 00:03:29 --> 00:03:36 Its given in delta underscore delta L and delta underscore T 32 00:03:37 --> 00:03:47 We shall again initialize the sequence values in the same manner as we did for L and T. 33 00:03:48 --> 00:03:59 Now to plot L vs T square with an error bar we use the function errorbar() . 34 00:04:00 --> 00:04:04 Before plotting the data we need to get the data of delta L and delta T 35 00:04:05 --> 00:04:24 delta L= within square bracket 0.08,0.09,0.07,0.05,0.06,0.00,0.06,0.06,0.01 36 00:04:25 --> 00:04:39 delta T= [0.04,0.08,0.03,0.05,0.03,0.03,0.04,0.07,0.08] 37 00:04:40 --> 00:04:43 Now use the error function 38 00:04:44 --> 00:05:31 Type errorbar within bracket L comma Tsquare comma xerr=delta underscore L comma yerr=delta underscore T comma fmt= in single quote bo 39 00:05:32 --> 00:05:35 This gives a plot with error bar of x and y axis. 40 00:05:36 --> 00:05:37 The dots are of blue color. 41 00:05:38 --> 00:05:45 The parameters xerr and yerr are error on x and y axis and fmt is the format of the plot. 42 00:05:46 --> 00:05:58 similarly we can draw the same error bar with small red dots just change the parameters of fmt to r dot. 43 00:05:59 --> 00:06:23 Type clf() to clear the plot errorbar within bracket L comma Tsquare comma xerr=delta underscore L comma yerr=delta underscore T comma fmt=in single quote r and hit enter. 44 00:06:24 --> 00:06:29 you can explore other options to errorbar using the documentation of errorbar. 45 00:06:30 --> 00:06:37 errorbar? on terminal 46 00:06:38 --> 00:06:43 Pause the video here, try out the following exercise and resume the video. 47 00:06:44 --> 00:06:50 Plot the given experimental data with small dots and also include the error in your plot. 48 00:06:51 --> 00:06:59 The data is on your screen for delta s delta n 49 00:07:00 --> 00:07:02 This brings us to the end of the end of this tutorial. 50 00:07:03 --> 00:07:08 In this tutorial, we have learnt to, 1. to declare a sequence of numbers using the function array. 51 00:07:09 --> 00:07:13 2. to perform elementwise squaring using the square function. 52 00:07:14 --> 00:07:19 3. to use the various options available for plotting like dots,lines. 53 00:07:20 --> 00:07:27 4. to Plot experimental data such that we can also represent error by using the errorbar() function. 54 00:07:28 --> 00:07:31 Here are some self assessment questions for you to solve 55 00:07:32 --> 00:07:43 1. Square the following sequence.br distance underscore values=within square bracket 2.1 comma 4.6 comma 8.72 comma 9.03 56 00:07:44 --> 00:07:51 2. Plot L versus T in red pluses. 57 00:07:52 --> 00:07:54 And the answers, 58 00:07:55 --> 00:08:01 1. To square a sequence of values, we use the function square 59 00:08:02 --> 00:08:08 So that we have to Type square within bracket distance underscore values 60 00:08:09 --> 00:08:13 2. We pass an additional argument stating the desired parameter 61 00:08:14 --> 00:08:23 Type plot within bracket L comma T comma within single quote r+ 62 00:08:24 --> 00:08:26 Hope you have enjoyed this tutorial and found it useful. 63 00:08:27 --> 00:08:32 Thank You!