Difference between revisions of "Python-3.4.3/C2/Plotting-Charts/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with " {| border=1 | '''Time''' | '''Narration''' |- | 00:01 | Hello friends. Welcome to the tutorial on '''plotting charts''' |- | 00:06 | At the end of this tutorial, you will...")
 
 
Line 245: Line 245:
 
|-
 
|-
 
| 06:45
 
| 06:45
| And the answer is,  '''bar x ''comma'' y ''comma'' fill '' is equal to'' False ''comma'' hatch ''is equal to'' a vertical line)''' is the correct option to generate a '''bar''' '''chart''' with vertical '''line''' '''hatching'''.
+
| And the answer is,  '''bar x ''comma'' y ''comma'' fill '' is equal to'' False ''comma'' hatch ''is equal to'' a vertical line''' is the correct option to generate a '''bar''' '''chart''' with vertical '''line''' '''hatching'''.
  
 
|-
 
|-

Latest revision as of 15:27, 13 June 2019

Time Narration
00:01 Hello friends. Welcome to the tutorial on plotting charts
00:06 At the end of this tutorial, you will be able to

Create pie charts

Create bar charts and

Find more information on matplotlib

00:18 To record this tutorial, I am using

Ubuntu Linux 14.04 operating system

00:24 Python 3.4.3 and IPython 5.1.0
00:31 To practice this tutorial, you should know how to

run basic Python commands on the ipython console

00:39 Load data from files and Plot data.
00:42 If not, see the relevant Python tutorials on this website.
00:47 Let us first open the Terminal by pressing Ctrl+Alt+T keys simultaneously.

Now, type ipython3 and press Enter.

00:58 Let us initialize the pylab package.

Type %pylab and press Enter.

01:06 A pie chart is a circular chart divided into sectors, to illustrate numerical proportion
01:12 The syntax for pie() function is as follows: pie inside parentheses values comma labels equal to labels
01:22 Where values are the data to be plotted and labels – the label for each wedge in the pie chart
01:30 Plot a pie chart representing the profit percentage of company A.
01:35 Use the data from file company-a-data.txt available in the code file link of this tutorial
01:43 The data file has two columns with a set of values in each column.
01:48 The first column represents years. The second column represents the profit percentages.
01:55 To produce a scatter plot, we first need to load the data from the file using loadtxt command.
02:03 Let us clear the terminal.

Type year comma profit equal to loadtxt inside parentheses inside single quotes add the path of the file company-a-data.txt comma unpack equal to True and press Enter

02:28 unpack equal to True --> returns the transposed array of data.
02:33 Type clf open and close parentheses to clear the plot window, if any plots executed previously.
02:41 Type pie(profit comma labels equal to year) and press Enter.
02:50 Notice that we passed two arguments to the function pie().
02:55 First one being the values, which is profit in our case.
02:59 The next one being the set of labels to be used in the pie chart, which is year in our case.
03:05 Pause the video here.

Try out the following exercise and resume the video.

03:11 Plot a pie chart with the same data with the following colors for each wedges.

white, red, black, magenta,

03:19 yellow, blue, green, cyan,
03:21 yellow, magenta and blue.
03:24 Hint: In your ipython interpreter, try typing pie question mark.
03:29 Solution to Exercise 2

Clear the plot window by typing clf open and close parentheses and press Enter.

03:39 Type pie inside parentheses profit comma labels equal to year comma colors equal to inside parentheses the color codes and press Enter.
03:57 This will display a pie chart with each wedge having the color as specified in the parameters.
04:04 A bar chart is a chart with rectangular bars

with lengths proportional to the values that they represent.

04:12 The syntax for bar chart is: bar inside parentheses x comma y

where x a sequence of data and y a sequence of data, the same length of x

04:28 Plot a bar chart representing the profit percentage of company A.
04:33 Use the data from file company-a-data.txt.
04:38 Solution to Exercise 3

Clear the plot window by typing clf open and close parentheses

04:47 Type bar open and close parentheses year comma profit and press Enter.
04:56 This will display a bar chart representing the profit percentage of company A
05:02 Plot a bar chart as shown in the image:

Hint: Bar chart is not filled and which is hatched with 45o slanting lines.

05:13 The data for the chart may be obtained from the file company-a-data.txt.
05:19 Hint: In your ipython interpreter, try typing bar question mark
05:25 Solution to Exercise 4

Clear the plot window by typing clf open and close parentheses

05:33 Type bar open and close parentheses year comma profit comma fill equal to False comma hatch equal to inside single quotes slanting line and press Enter.
05:54 This will display a bar chart which is not filled and which is hatched with 45o slanting lines
06:02 Help about matplotlib can be obtained from matplotlib.sourceforge.net/contents.html

More plots can be seen at the following links

06:18 This brings us to the end of this tutorial.

In this tutorial we learnt to, Plot a pie chart using pie() function

06:28 Plot a bar chart using bar() function
06:31 And Access the matplotlib online help
06:34 Here are some self assessment questions for you to solve.
06:38 What statement can be issued to generate a bar chart with vertical line hatching?
06:45 And the answer is, bar x comma y comma fill is equal to False comma hatch is equal to a vertical line is the correct option to generate a bar chart with vertical line hatching.
07:00 Please post your timed queries in this forum.
07:04 Please post your general queries on Python in this forum.
07:09 FOSSEE team coordinates the TBC project.
07:13 Spoken Tutorial Project is funded by NMEICT, MHRD, Govt. of India.

For more details, visit this website.

07:23 This is Trupti Kini from FOSSEE IIT Bombay signing off.

Thank you.

Contributors and Content Editors

PoojaMoolya