Difference between revisions of "Python/C2/Other-types-of-plots/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{| border=1
 
{| border=1
!Visual Cue
+
|'''Time'''
!Narration
+
|'''Narration'''
 
|-
 
|-
| 0:01
+
| 00:01
 
| Hello Friends and welcome to the tutorial on Other types of plots
 
| Hello Friends and welcome to the tutorial on Other types of plots
  
 
|-
 
|-
| 0:06
+
| 00:06
 
| Till now we have seen only one kind of plotting.
 
| Till now we have seen only one kind of plotting.
  
 
|-
 
|-
| 0:10
+
| 00:10
 
| Hence in this tutorial we will be looking at some more kinds of plots.
 
| Hence in this tutorial we will be looking at some more kinds of plots.
  
 
|-
 
|-
| 0:16
+
| 00:16
 
|At the end of this tutorial, you will be able to
 
|At the end of this tutorial, you will be able to
 
+
Create scatter plot
# Create scatter plot
+
Create pie charts
# Create pie charts
+
Create bar charts
# Create bar charts
+
Create log-log plots
# Create log-log plots
+
Use the matplotlib help
# Use the matplotlib help
+
  
 
|-
 
|-
|0:29
+
|00:29
 
| So let us begin with scatter plot
 
| So let us begin with scatter plot
  
 
|-
 
|-
| 0:33
+
| 00:33
 
| Before beginning this tutorial,we would suggest you to complete the tutorial on "Loading data from files" and "Plotting data".
 
| Before beginning this tutorial,we would suggest you to complete the tutorial on "Loading data from files" and "Plotting data".
  
 
|-
 
|-
| 0:42
+
| 00:42
 
| In a scatter plot, the data is displayed as a collection of points, where each point determines it's position on the horizontal axis and the vertical axis respectively.
 
| In a scatter plot, the data is displayed as a collection of points, where each point determines it's position on the horizontal axis and the vertical axis respectively.
  
 
|-
 
|-
| 0:54
+
| 00:54
 
| This kind of plot is also called a scatter chart, a scatter diagram or a scatter graph.
 
| This kind of plot is also called a scatter chart, a scatter diagram or a scatter graph.
  
 
|-
 
|-
| 1:01
+
| 01:01
 
| Before we proceed further , start your IPython interpreter
 
| Before we proceed further , start your IPython interpreter
  
 
|-
 
|-
|1:06
+
|01:06
 
|So type ipython hypen pylab
 
|So type ipython hypen pylab
  
 
|-
 
|-
| 1:13
+
| 01:13
 
| Plot a scatter plot showing the percentage profit of a company A from the year 2000-2010.
 
| Plot a scatter plot showing the percentage profit of a company A from the year 2000-2010.
  
 
|-
 
|-
| 1:22
+
| 01:22
 
| The data for the same is available in the file company-a-data.txt.
 
| The data for the same is available in the file company-a-data.txt.
  
 
|-
 
|-
|1:33
+
|01:33
|Type cat space slash home slash fossee bacslash other-plot slash company-a-data.txt (enter)
+
|Type cat space slash home slash fossee slash other-plot slash company-a-data.txt (enter)
  
 
|-
 
|-
| 1:50
+
| 01:50
 
| The data file has two lines with a set of values in each line, the first line representing years and the second line representing the profit percentages.
 
| The data file has two lines with a set of values in each line, the first line representing years and the second line representing the profit percentages.
  
 
|-
 
|-
|2:02
+
|02:02
 
| To produce the scatter plot, we first need to load the data from the file using loadtxt command.
 
| To produce the scatter plot, we first need to load the data from the file using loadtxt command.
  
 
|-
 
|-
|2:10
+
|02:10
 
|Type year,profit = loadtxt within bracket in single quote slash home slash fossee slash other-plot slash company-a-data.txt comma dtype=type in bracket int()closing brackets hit enter
 
|Type year,profit = loadtxt within bracket in single quote slash home slash fossee slash other-plot slash company-a-data.txt comma dtype=type in bracket int()closing brackets hit enter
 
  
 
|-
 
|-
| 2:52
+
| 02:52
 
| By default loadtxt converts the value to float.
 
| By default loadtxt converts the value to float.
  
 
|-
 
|-
| 2:57
+
| 02:57
 
| The dtype=type within bracket int() closing bracket argument in loadtxt converts the value to integer, as we require the data as integer further in the tutorial.
 
| The dtype=type within bracket int() closing bracket argument in loadtxt converts the value to integer, as we require the data as integer further in the tutorial.
  
 
|-
 
|-
| 3:11
+
| 03:11
 
| Now in-order to generate the scatter graph we will use the function scatter()closing brackets
 
| Now in-order to generate the scatter graph we will use the function scatter()closing brackets
 
|-
 
|-
|3:18
+
|03:18
 
|Type scatter within closing bracket year comma profit and hit enter
 
|Type scatter within closing bracket year comma profit and hit enter
  
 
|-
 
|-
| 3:32
+
| 03:32
 
| Notice that we passed two arguments to scatter() function, first one the values in x-coordinate, year, and the other the values in y-coordinate, the profit percentage.
 
| Notice that we passed two arguments to scatter() function, first one the values in x-coordinate, year, and the other the values in y-coordinate, the profit percentage.
  
 
|-
 
|-
| 3:57
+
| 03:57
 
| Plot a scatter plot of the same data in company-a-data.txt with red diamond markers.
 
| Plot a scatter plot of the same data in company-a-data.txt with red diamond markers.
  
 
|-
 
|-
| 4:09
+
| 04:09
 
| Pause the video here, try out the following exercise and resume the video.
 
| Pause the video here, try out the following exercise and resume the video.
  
 
|-
 
|-
| 4:17
+
| 04:17
 
|Now let us see another kind of plot, the pie chart, for the same data.
 
|Now let us see another kind of plot, the pie chart, for the same data.
  
 
|-
 
|-
| 4:40
+
| 04:40
 
| A pie chart or a circle graph is a circular chart divided into sectors, illustrating proportion.
 
| A pie chart or a circle graph is a circular chart divided into sectors, illustrating proportion.
  
 
|-
 
|-
| 4:49
+
| 04:49
| Plot a pie chart representing the profit percentage of company A, with the same data from file company-a-data.tx.
+
| Plot a pie chart representing the profit percentage of company A, with the same data from file company-a-data.txt.
  
 
|-
 
|-
| 5:00
+
| 05:00
 
|So let us reuse the data we have loaded from the file previously.
 
|So let us reuse the data we have loaded from the file previously.
  
 
|-
 
|-
| 5:11
+
| 05:11
 
| We can plot the pie chart using the function pie()closing brackets
 
| We can plot the pie chart using the function pie()closing brackets
  
 
|-
 
|-
|5:15
+
|05:15
 
|So Type pie within bracket profit comma labels=year
 
|So Type pie within bracket profit comma labels=year
 
  
 
|-
 
|-
| 5:29
+
| 05:29
 
| Notice that we passed two arguments to the function pie().
 
| Notice that we passed two arguments to the function pie().
  
 
|-
 
|-
| 5:33
+
| 05:33
 
| First one the values and the next one the set of labels to be used in the pie chart.
 
| First one the values and the next one the set of labels to be used in the pie chart.
  
 
|-
 
|-
| 5:38
+
| 05:38
| Plot a pie chart with the same data with red colors for each wedges as white, red, black, magenta,yellow, blue, green, cyan, yellow, magenta and blue respectively.
+
| Plot a pie chart with the same data with colors for each wedges as white, red, black, magenta,yellow, blue, green, cyan, yellow, magenta and blue respectively.
  
 
|-
 
|-
| 5:58
+
| 05:58
 
| Pause the video here, try out the following exercise and resume the video.
 
| Pause the video here, try out the following exercise and resume the video.
  
 
|-
 
|-
6:05
+
06:05
 
| Now let us move on to the bar charts.
 
| Now let us move on to the bar charts.
  
 
|-
 
|-
| 6:08
+
| 06:08
 
| A bar chart or bar graph is a chart with rectangular bars with lengths proportional to the values that they represent.
 
| A bar chart or bar graph is a chart with rectangular bars with lengths proportional to the values that they represent.
  
 
|-
 
|-
| 6:19
+
| 06:19
 
| Plot a bar chart representing the profit percentage of company A, with the same data from file company-a-data.txt.
 
| Plot a bar chart representing the profit percentage of company A, with the same data from file company-a-data.txt.
  
 
|-
 
|-
| 6:30
+
| 06:30
 
|So let us reuse the data we have loaded from the file previously.
 
|So let us reuse the data we have loaded from the file previously.
  
 
|-
 
|-
| 6:34
+
| 06:34
 
| We can plot the bar chart using the function bar() and hit enter.
 
| We can plot the bar chart using the function bar() and hit enter.
  
 
|-
 
|-
|6:44
+
|06:44
|So inside that bracket you can put bar , year ,comma profit
+
|So inside that bracket you can put bar ( year , profit )
  
 
|-
 
|-
| 6:52
+
| 06:52
 
| Note that the function bar()needs at least two arguments one the values in x-coordinate and the other values in y-coordinate which is used to determine the height of the bars.
 
| Note that the function bar()needs at least two arguments one the values in x-coordinate and the other values in y-coordinate which is used to determine the height of the bars.
  
 
|-
 
|-
| 7:05
+
| 07:05
| Plot a bar chart which is not filled and which is hatched with 45 slanting lines as shown in the image.
+
| Plot a bar chart which is not filled and which is hatched with 45 degree  slanting lines as shown in the image.
  
 
|-
 
|-
| 7:17
+
| 07:17
 
|The data for the chart may be obtained from the file company-a-data.txt
 
|The data for the chart may be obtained from the file company-a-data.txt
  
 
|-
 
|-
|7:26
+
|07:26
 
|Type bar within bracket year comma profit comma fill=False comma hatch=  within single quote slashhit enter
 
|Type bar within bracket year comma profit comma fill=False comma hatch=  within single quote slashhit enter
  
 
|-
 
|-
| 8:05
+
| 08:05
 
| Now let us move on to the log-log plot.
 
| Now let us move on to the log-log plot.
  
 
|-
 
|-
| 8:10
+
| 08:10
 
| A log-log graph or a log-log plot is a two-dimensional graph of numerical data that uses logarithmic scales on both the horizontal and vertical axes.
 
| A log-log graph or a log-log plot is a two-dimensional graph of numerical data that uses logarithmic scales on both the horizontal and vertical axes.
  
 
|-
 
|-
| 8:24
+
| 08:24
| Because of the nonlinear scaling of the axes, a function of the form y = ax b will appear as a straight line on a log-log graph
+
| Because of the nonlinear scaling of the axes, a function of the form ''y = ax^b will appear as a straight line on a log-log graph
  
 
|-
 
|-
8:38
+
08:38
 
| Plot a ''log-log'' chart of y=5 into x3for x from 1-20.
 
| Plot a ''log-log'' chart of y=5 into x3for x from 1-20.
  
 
|-
 
|-
| 8:49
+
| 08:49
 
| Before we actually plot let us calculate the points needed for that.
 
| Before we actually plot let us calculate the points needed for that.
  
 
|-
 
|-
|8:54
+
|08:54
 
|x = linspace within brackets 1 comma 20 comma 100
 
|x = linspace within brackets 1 comma 20 comma 100
y = 5 into x into 3
+
y = 5 into x into 3
  
 
|-
 
|-
| 9:23
+
| 09:23
 
| Here is the syntax of the log-log function.
 
| Here is the syntax of the log-log function.
  
 
|-
 
|-
| 9:28
+
| 09:28
 
| Now we can plot the log-log chart using loglog()function,
 
| Now we can plot the log-log chart using loglog()function,
  
 
|-
 
|-
|9:34
+
|09:34
 
|Type loglog within brackets x comma y hit enter
 
|Type loglog within brackets x comma y hit enter
  
 
|-
 
|-
| 9:48
+
| 09:48
 
| To understand the difference between a normal plot and a log-log plot let us create another plot using the function plot.
 
| To understand the difference between a normal plot and a log-log plot let us create another plot using the function plot.
  
 
|-
 
|-
|9:57
+
|09:57
 
|figure within brackets 2 THen type plot within brackets x comma y
 
|figure within brackets 2 THen type plot within brackets x comma y
  
Line 248: Line 245:
 
|-
 
|-
 
| 11:20
 
| 11:20
| 1. Plot a scatter plot using scatter() function
+
|Plot a scatter plot using scatter() function
  
 
|-
 
|-
 
| 11:22
 
| 11:22
| 2. Plot a pie chart using pie() function
+
|Plot a pie chart using pie() function
  
 
|-
 
|-
 
| 11:25
 
| 11:25
| 3. Plot a bar chart using bar() function
+
|Plot a bar chart using bar() function
  
 
|-
 
|-
 
| 11:28
 
| 11:28
| 4. Plot a log-log graph using loglog() function
+
|Plot a log-log graph using loglog() function
  
 
|-
 
|-
 
| 11:33
 
| 11:33
| 5. Access the matplotlib online help.Thank you.
+
| Access the matplotlib online help.Thank you.
  
 
|-
 
|-
Line 272: Line 269:
 
|-
 
|-
 
| 11:46
 
| 11:46
|1. scatter  x comma y comma  color=blue  marker= d  and plot  x comma y comma color=b  comma marker= d) does exactly the same.
+
|scatter  x comma y comma  color=blue  marker= d  and plot  x comma y comma color=b  comma marker= d) does exactly the same.
  
 
|-
 
|-
Line 280: Line 277:
 
|-
 
|-
 
| 12:07
 
| 12:07
| 2. What statement can be issued to generate a bar chart with vertical line hatching.
+
| What statement can be issued to generate a bar chart with vertical line hatching.
  
 
|-
 
|-
 
| 12:15
 
| 12:15
| 1.bar  within function  x comma y comma color=in single quote w  comma hatch= slash
+
|bar  within function  x comma y comma color=in single quote w  comma hatch= slash
  
 
|-
 
|-
 
| 12:27
 
| 12:27
|2. bar within bracket x comma y comma fill=False comma hatch=slash  slash
+
| bar within bracket x comma y comma fill=False comma hatch=slash  slash
  
 
|-
 
|-
 
| 12:38
 
| 12:38
| bar  within bracket x comma y comma fill=False comma hatch=in single quote|
+
| bar  within bracket x comma y comma fill=False comma hatch=in single quote
  
 
|-
 
|-
Line 304: Line 301:
 
|-
 
|-
 
| 13:06
 
| 13:06
| 1. False.
+
| False.
  
 
|-
 
|-
| 13:9
+
| 13:09
 
| Both functions do not produce the same kind of plot.
 
| Both functions do not produce the same kind of plot.
  
 
|-
 
|-
 
| 13:13
 
| 13:13
| 2.bar  x comma y comma fill=False comma hatch=bar is the correct option to generate a bar chart with vertical line hatching.
+
| bar  x comma y comma fill=False comma hatch=bar is the correct option to generate a bar chart with vertical line hatching.
  
 
|-
 
|-

Latest revision as of 17:51, 20 February 2017

Time Narration
00:01 Hello Friends and welcome to the tutorial on Other types of plots
00:06 Till now we have seen only one kind of plotting.
00:10 Hence in this tutorial we will be looking at some more kinds of plots.
00:16 At the end of this tutorial, you will be able to

Create scatter plot Create pie charts Create bar charts Create log-log plots Use the matplotlib help

00:29 So let us begin with scatter plot
00:33 Before beginning this tutorial,we would suggest you to complete the tutorial on "Loading data from files" and "Plotting data".
00:42 In a scatter plot, the data is displayed as a collection of points, where each point determines it's position on the horizontal axis and the vertical axis respectively.
00:54 This kind of plot is also called a scatter chart, a scatter diagram or a scatter graph.
01:01 Before we proceed further , start your IPython interpreter
01:06 So type ipython hypen pylab
01:13 Plot a scatter plot showing the percentage profit of a company A from the year 2000-2010.
01:22 The data for the same is available in the file company-a-data.txt.
01:33 Type cat space slash home slash fossee slash other-plot slash company-a-data.txt (enter)
01:50 The data file has two lines with a set of values in each line, the first line representing years and the second line representing the profit percentages.
02:02 To produce the scatter plot, we first need to load the data from the file using loadtxt command.
02:10 Type year,profit = loadtxt within bracket in single quote slash home slash fossee slash other-plot slash company-a-data.txt comma dtype=type in bracket int()closing brackets hit enter
02:52 By default loadtxt converts the value to float.
02:57 The dtype=type within bracket int() closing bracket argument in loadtxt converts the value to integer, as we require the data as integer further in the tutorial.
03:11 Now in-order to generate the scatter graph we will use the function scatter()closing brackets
03:18 Type scatter within closing bracket year comma profit and hit enter
03:32 Notice that we passed two arguments to scatter() function, first one the values in x-coordinate, year, and the other the values in y-coordinate, the profit percentage.
03:57 Plot a scatter plot of the same data in company-a-data.txt with red diamond markers.
04:09 Pause the video here, try out the following exercise and resume the video.
04:17 Now let us see another kind of plot, the pie chart, for the same data.
04:40 A pie chart or a circle graph is a circular chart divided into sectors, illustrating proportion.
04:49 Plot a pie chart representing the profit percentage of company A, with the same data from file company-a-data.txt.
05:00 So let us reuse the data we have loaded from the file previously.
05:11 We can plot the pie chart using the function pie()closing brackets
05:15 So Type pie within bracket profit comma labels=year
05:29 Notice that we passed two arguments to the function pie().
05:33 First one the values and the next one the set of labels to be used in the pie chart.
05:38 Plot a pie chart with the same data with colors for each wedges as white, red, black, magenta,yellow, blue, green, cyan, yellow, magenta and blue respectively.
05:58 Pause the video here, try out the following exercise and resume the video.
06:05 Now let us move on to the bar charts.
06:08 A bar chart or bar graph is a chart with rectangular bars with lengths proportional to the values that they represent.
06:19 Plot a bar chart representing the profit percentage of company A, with the same data from file company-a-data.txt.
06:30 So let us reuse the data we have loaded from the file previously.
06:34 We can plot the bar chart using the function bar() and hit enter.
06:44 So inside that bracket you can put bar ( year , profit )
06:52 Note that the function bar()needs at least two arguments one the values in x-coordinate and the other values in y-coordinate which is used to determine the height of the bars.
07:05 Plot a bar chart which is not filled and which is hatched with 45 degree slanting lines as shown in the image.
07:17 The data for the chart may be obtained from the file company-a-data.txt
07:26 Type bar within bracket year comma profit comma fill=False comma hatch= within single quote slashhit enter
08:05 Now let us move on to the log-log plot.
08:10 A log-log graph or a log-log plot is a two-dimensional graph of numerical data that uses logarithmic scales on both the horizontal and vertical axes.
08:24 Because of the nonlinear scaling of the axes, a function of the form y = ax^b will appear as a straight line on a log-log graph
08:38 Plot a log-log chart of y=5 into x3for x from 1-20.
08:49 Before we actually plot let us calculate the points needed for that.
08:54 x = linspace within brackets 1 comma 20 comma 100

y = 5 into x into 3

09:23 Here is the syntax of the log-log function.
09:28 Now we can plot the log-log chart using loglog()function,
09:34 Type loglog within brackets x comma y hit enter
09:48 To understand the difference between a normal plot and a log-log plot let us create another plot using the function plot.
09:57 figure within brackets 2 THen type plot within brackets x comma y
10:24 The difference is clear.So that was log-log() plot.
10:33 Now we will see few more plots and also see how to access help of matplotlib over the Internet.
10:43 Help about matplotlib can be obtained from matplotlib.sourceforge.net/contents.html
10:55 More plots can be seen at matplotlib.sourceforge.net slash users slash screenshots.html and also at matplotlib.sourceforge.net slash gallery.html
11:13 This brings us to the end of this tutorial. In this tutorial we learnt to,
11:20 Plot a scatter plot using scatter() function
11:22 Plot a pie chart using pie() function
11:25 Plot a bar chart using bar() function
11:28 Plot a log-log graph using loglog() function
11:33 Access the matplotlib online help.Thank you.
11:42 So there are few some self assessment questions for you to solve.
11:46 scatter x comma y comma color=blue marker= d and plot x comma y comma color=b comma marker= d) does exactly the same.
12:04 Is True or False?
12:07 What statement can be issued to generate a bar chart with vertical line hatching.
12:15 bar within function x comma y comma color=in single quote w comma hatch= slash
12:27 bar within bracket x comma y comma fill=False comma hatch=slash slash
12:38 bar within bracket x comma y comma fill=False comma hatch=in single quote
12:52 bar within bracket x comma y comma color= within quote w comma hatch=single quote
13:02 And now the answers,
13:06 False.
13:09 Both functions do not produce the same kind of plot.
13:13 bar x comma y comma fill=False comma hatch=bar is the correct option to generate a bar chart with vertical line hatching.
13:31 Hope you have enjoyed this tutorial and found it useful.
13:34 Thank you!

Contributors and Content Editors

Gaurav, Jyotisolanki, Minal, PoojaMoolya, Ranjana, Sneha