Python-3.4.3/C2/Other-Types-Of-Plots/English-timed
| Time | Narration |
| 00:01 | Hello friends. Welcome to the tutorial on Other types of plots |
| 00:06 | At the end of this tutorial, you will be able to -
Create scatter plot Create log-log plots |
| 00:15 | To record this tutorial, I am using
Ubuntu Linux 14.04 operating system Python 3.4.3 IPython 5.1.0 |
| 00:29 | To practice this tutorial, you should know how to
Run basic Python commands on the ipython console Load data from files and Plot data. |
| 00:41 | If not, see the relevant Python tutorials on this website. |
| 00:46 | Let us first open the Terminal by pressing Ctrl+Alt+T keys simultaneously.
Now, type ipython3 and press Enter. |
| 00:58 | Let us initialise the pylab package. Type percent pylab and press Enter. |
| 01:08 | In a scatter plot, the data is displayed as a collection of points. |
| 01:13 | Each point determines its position on the x and y axes |
| 01:18 | Plot a scatter plot showing the percentage profit of a company A from the year 2000 to 2010. |
| 01:27 | The data for the same is available in the file company hyphen a hyphen data dot txt. |
| 01:35 | company hyphen a hyphen data dot txt file is available in the code file link of this tutorial. Please download and use it. |
| 01:45 | Let us see the content of the file company hyphen a hyphen data dot txt. |
| 01:52 | So type,cat company hyphen a hyphen data dot txt. and press Enter |
| 02:00 | The data file has two columns with a set of values in each column. |
| 02:06 | The first column represents the years. And the second column represents the profit percentage. |
| 02:15 | To produce the scatter plot, we first need to load the data from the file using loadtxt command. |
| 02:22 | So Type
year comma profit equal to loadtxt within parentheses within single quotes company hyphen a hyphen data dot txt after single quotes comma unpack equal to True and Press Enter |
| 02:45 | unpack equal to True returns the transposed array of data |
| 02:51 | scatter() function is used to generate the scatter graph |
| 02:56 | Syntax: scatter within parentheses x comma y
x is a sequence of data y is a sequence of data having the same length of x |
| 03:11 | Let us use scatter function to plot scatter graph for data stored in year and profit. |
| 03:20 | So Type scatter within parentheses year comma profit and press Enter. |
| 03:31 | Notice that we passed two arguments to scatter() function. |
| 03:36 | The First one being the values in x-coordinate that is year. Second, the values in y-coordinate, the profit percentages. |
| 03:48 | Pause the video here, try out the following exercise and resume the video. Read the documentation of scatter. |
| 03:58 | Plot a scatter plot of same data in company hyphen a hyphen data dot txt with red diamond markers. |
| 04:08 | Solution to Exercise Clear the plot window by typing clf parentheses and press Enter |
| 04:20 | Now type
scatter within parentheses year comma profit comma color equal to within single quotes r comma marker equal to within single quotes d and press Enter |
| 04:43 | Thus, we got our scatter plot. Now let us see another kind of plot. |
| 04:51 | A log-log plot is a two-dimensional graph of numerical data. |
| 04:57 | It uses logarithmic scales on both axes. |
| 05:02 | Graph appears as straight line due to non-linear scaling |
| 05:08 | Syntax
loglog within parentheses x comma y x is a sequence of data y is a sequence of data, having the same length of x |
| 05:24 | Plot a log-log chart of y equal to 5 times x cube for x from 1 to 20. |
| 05:33 | Before we actually plot, let us calculate the points needed for that. |
| 05:39 | Type x equalto linspace within parentheses 1 comma 20 comma 100 and press Enter |
| 05:54 | Then, y equal to 5 into x raised to 3 and press Enter |
| 06:06 | Clear the plot window by typing clf parentheses and press Enter |
| 06:14 | Type loglog within parentheses x comma y and press Enter |
| 06:24 | We see the required plot |
| 06:27 | This brings us to the end of this tutorial. In this tutorial we learnt to,
Plot a scatter plot using scatter() function Plot a log-log graph using loglog() function |
| 06:42 | Here are some self assessment questions for you to solve. |
| 06:46 | scatter within parentheses x comma y comma color equal to within single quotes blue comma marker equal to within single quotes d |
| 06:59 | and plot within parentheses x comma y comma color equal to within single quotes b comma marker equal to within single quotes d |
| 07:11 | does exactly the same?
True or False |
| 07:17 | And the answer, False. Both functions do not produce the same kind of plot. |
| 07:25 | Please post your timed queries in this forum. |
| 07:25 | Please post your general queries on Python in this forum. |
| 07:29 | FOSSEE team coordinates the TBC project. |
| 07:33 | Spoken Tutorial Project is funded by NMEICT, MHRD, Govt. of India.For more details, visit this website. |
| 07:42 | This is Prathamesh Salunkhe from IIT Bombay (or FOSSEE, if you wish) signing off. Thank you. |