├── 002_Python_Matplotlib_Exercise_1.ipynb
├── 003_Python_Matplotlib_Exercise_2.ipynb
├── Gas_price_figure.png
├── LICENSE
├── Matplotlib Cheat Sheet Plotting in Python.pdf
├── README.md
├── barchart.png
├── company_sales_data.csv
├── dnld_rep.png
├── fifa_data.csv
├── gas_prices.csv
├── histogram.png
├── img
├── dnld_rep.png
├── ex1_1.png
├── ex1_10.png
├── ex1_2.png
├── ex1_3.png
├── ex1_4.png
├── ex1_5.png
├── ex1_6.png
├── ex1_7.png
├── ex1_8.png
├── ex1_9.png
├── ex2_1.png
├── ex2_10.png
├── ex2_2.png
├── ex2_3.png
├── ex2_4.png
├── ex2_5.png
├── ex2_6.png
├── ex2_7.png
├── ex2_8.png
└── ex2_9.png
├── iris_data.csv
├── mygraph.png
└── sales_data_of_bathingsoap.png
/002_Python_Matplotlib_Exercise_1.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "\n",
8 | "All the IPython Notebooks in this lecture series by Dr. Milan Parmar are available @ **[GitHub](https://github.com/milaan9/11_Python_Matplotlib_Module)**\n",
9 | ""
10 | ]
11 | },
12 | {
13 | "cell_type": "markdown",
14 | "metadata": {},
15 | "source": [
16 | "# Python Matplotlib\n",
17 | "\n",
18 | "**[Matplotlib](https://matplotlib.org/)** is a Python 2D plotting library that produces high-quality charts and figures, which helps us visualize extensive data to understand better. Pandas is a handy and useful data-structure tool for analyzing large and complex data."
19 | ]
20 | },
21 | {
22 | "cell_type": "markdown",
23 | "metadata": {},
24 | "source": [
25 | "### Load Necessary Libraries"
26 | ]
27 | },
28 | {
29 | "cell_type": "code",
30 | "execution_count": 1,
31 | "metadata": {
32 | "ExecuteTime": {
33 | "end_time": "2021-07-04T12:44:01.238492Z",
34 | "start_time": "2021-07-04T12:44:00.049041Z"
35 | }
36 | },
37 | "outputs": [],
38 | "source": [
39 | "import matplotlib.pyplot as plt\n",
40 | "import numpy as np\n",
41 | "import pandas as pd"
42 | ]
43 | },
44 | {
45 | "cell_type": "markdown",
46 | "metadata": {},
47 | "source": [
48 | "### Basic Graph"
49 | ]
50 | },
51 | {
52 | "cell_type": "code",
53 | "execution_count": null,
54 | "metadata": {
55 | "ExecuteTime": {
56 | "end_time": "2021-07-04T12:30:48.486380Z",
57 | "start_time": "2021-07-04T12:30:46.481499Z"
58 | }
59 | },
60 | "outputs": [],
61 | "source": [
62 | "x = [0,1,2,3,4]\n",
63 | "y = [0,2,4,6,8]\n",
64 | "\n",
65 | "# Resize your Graph (dpi specifies pixels per inch. When saving probably should use 300 if possible)\n",
66 | "plt.figure(figsize=(8,5), dpi=100)\n",
67 | "\n",
68 | "# Line 1\n",
69 | "\n",
70 | "# Keyword Argument Notation\n",
71 | "#plt.plot(x,y, label='2x', color='red', linewidth=2, marker='.', linestyle='--', markersize=10, markeredgecolor='blue')\n",
72 | "\n",
73 | "# Shorthand notation\n",
74 | "# fmt = '[color][marker][line]'\n",
75 | "plt.plot(x,y, 'b^--', label='2x')\n",
76 | "\n",
77 | "## Line 2\n",
78 | "\n",
79 | "# select interval we want to plot points at\n",
80 | "x2 = np.arange(0,4.5,0.5)\n",
81 | "\n",
82 | "# Plot part of the graph as line\n",
83 | "plt.plot(x2[:6], x2[:6]**2, 'r', label='X^2')\n",
84 | "\n",
85 | "# Plot remainder of graph as a dot\n",
86 | "plt.plot(x2[5:], x2[5:]**2, 'r--')\n",
87 | "\n",
88 | "# Add a title (specify font parameters with fontdict)\n",
89 | "plt.title('Our First Graph!', fontdict={'fontname': 'Comic Sans MS', 'fontsize': 20})\n",
90 | "\n",
91 | "# X and Y labels\n",
92 | "plt.xlabel('X Axis')\n",
93 | "plt.ylabel('Y Axis')\n",
94 | "\n",
95 | "# X, Y axis Tickmarks (scale of your graph)\n",
96 | "plt.xticks([0,1,2,3,4,])\n",
97 | "#plt.yticks([0,2,4,6,8,10])\n",
98 | "\n",
99 | "# Add a legend\n",
100 | "plt.legend()\n",
101 | "\n",
102 | "# Save figure (dpi 300 is good when saving so graph has high resolution)\n",
103 | "plt.savefig('mygraph.png', dpi=300)\n",
104 | "\n",
105 | "# Show plot\n",
106 | "plt.show()"
107 | ]
108 | },
109 | {
110 | "cell_type": "markdown",
111 | "metadata": {},
112 | "source": [
113 | "The line plot graph should look like this:\n",
114 | "
\n",
115 | "

\n",
116 | "
"
117 | ]
118 | },
119 | {
120 | "cell_type": "markdown",
121 | "metadata": {},
122 | "source": [
123 | "### Bar Chart"
124 | ]
125 | },
126 | {
127 | "cell_type": "code",
128 | "execution_count": null,
129 | "metadata": {
130 | "ExecuteTime": {
131 | "end_time": "2021-07-04T12:30:49.327203Z",
132 | "start_time": "2021-07-04T12:30:48.497612Z"
133 | }
134 | },
135 | "outputs": [],
136 | "source": [
137 | "labels = ['A', 'B', 'C']\n",
138 | "values = [1,4,2]\n",
139 | "\n",
140 | "plt.figure(figsize=(5,3), dpi=100)\n",
141 | "\n",
142 | "bars = plt.bar(labels, values)\n",
143 | "\n",
144 | "patterns = ['/', 'O', '*']\n",
145 | "for bar in bars:\n",
146 | " bar.set_hatch(patterns.pop(0))\n",
147 | "\n",
148 | "plt.savefig('barchart.png', dpi=300)\n",
149 | "\n",
150 | "plt.show()"
151 | ]
152 | },
153 | {
154 | "cell_type": "markdown",
155 | "metadata": {},
156 | "source": [
157 | "The line bar chart should look like this:\n",
158 | "\n",
159 | "

\n",
160 | "
"
161 | ]
162 | },
163 | {
164 | "cell_type": "markdown",
165 | "metadata": {},
166 | "source": [
167 | "# Real World Examples\n",
168 | "\n",
169 | "Download datasets from my Github: \n",
170 | "1. **[gas_prices.csv](https://github.com/milaan9/11_Python_Matplotlib_Module/blob/main/gas_prices.csv)** \n",
171 | "2. **[fifa_data.csv](https://github.com/milaan9/11_Python_Matplotlib_Module/blob/main/fifa_data.csv)**\n",
172 | "3. **[iris_data.csv](https://github.com/milaan9/11_Python_Matplotlib_Module/blob/main/iris_data.csv)**"
173 | ]
174 | },
175 | {
176 | "cell_type": "markdown",
177 | "metadata": {},
178 | "source": [
179 | "### Line Graph"
180 | ]
181 | },
182 | {
183 | "cell_type": "code",
184 | "execution_count": null,
185 | "metadata": {
186 | "ExecuteTime": {
187 | "end_time": "2021-07-04T12:30:50.709523Z",
188 | "start_time": "2021-07-04T12:30:49.336967Z"
189 | }
190 | },
191 | "outputs": [],
192 | "source": [
193 | "gas = pd.read_csv('gas_prices.csv')\n",
194 | "\n",
195 | "plt.figure(figsize=(8,5))\n",
196 | "\n",
197 | "plt.title('Gas Prices over Time (in USD)', fontdict={'fontweight':'bold', 'fontsize': 18})\n",
198 | "\n",
199 | "plt.plot(gas.Year, gas.USA, 'b.-', label='United States')\n",
200 | "plt.plot(gas.Year, gas.Canada, 'r.-')\n",
201 | "plt.plot(gas.Year, gas['South Korea'], 'g.-')\n",
202 | "plt.plot(gas.Year, gas.Australia, 'y.-')\n",
203 | "\n",
204 | "# Another Way to plot many values!\n",
205 | "# countries_to_look_at = ['Australia', 'USA', 'Canada', 'South Korea']\n",
206 | "# for country in gas:\n",
207 | "# if country in countries_to_look_at:\n",
208 | "# plt.plot(gas.Year, gas[country], marker='.')\n",
209 | "\n",
210 | "plt.xticks(gas.Year[::3].tolist()+[2011])\n",
211 | "\n",
212 | "plt.xlabel('Year')\n",
213 | "plt.ylabel('US Dollars')\n",
214 | "\n",
215 | "plt.legend()\n",
216 | "\n",
217 | "plt.savefig('Gas_price_figure.png', dpi=300)\n",
218 | "\n",
219 | "plt.show()"
220 | ]
221 | },
222 | {
223 | "cell_type": "markdown",
224 | "metadata": {},
225 | "source": [
226 | "The line graph should look like this:\n",
227 | "\n",
228 | "

\n",
229 | "
"
230 | ]
231 | },
232 | {
233 | "cell_type": "markdown",
234 | "metadata": {},
235 | "source": [
236 | "### Load Fifa Data"
237 | ]
238 | },
239 | {
240 | "cell_type": "code",
241 | "execution_count": 2,
242 | "metadata": {
243 | "ExecuteTime": {
244 | "end_time": "2021-07-04T12:44:11.002158Z",
245 | "start_time": "2021-07-04T12:44:10.222864Z"
246 | }
247 | },
248 | "outputs": [
249 | {
250 | "data": {
251 | "text/html": [
252 | "\n",
253 | "\n",
266 | "
\n",
267 | " \n",
268 | " \n",
269 | " | \n",
270 | " Unnamed: 0 | \n",
271 | " ID | \n",
272 | " Name | \n",
273 | " Age | \n",
274 | " Photo | \n",
275 | " Nationality | \n",
276 | " Flag | \n",
277 | " Overall | \n",
278 | " Potential | \n",
279 | " Club | \n",
280 | " ... | \n",
281 | " Composure | \n",
282 | " Marking | \n",
283 | " StandingTackle | \n",
284 | " SlidingTackle | \n",
285 | " GKDiving | \n",
286 | " GKHandling | \n",
287 | " GKKicking | \n",
288 | " GKPositioning | \n",
289 | " GKReflexes | \n",
290 | " Release Clause | \n",
291 | "
\n",
292 | " \n",
293 | " \n",
294 | " \n",
295 | " 0 | \n",
296 | " 0 | \n",
297 | " 158023 | \n",
298 | " L. Messi | \n",
299 | " 31 | \n",
300 | " https://cdn.sofifa.org/players/4/19/158023.png | \n",
301 | " Argentina | \n",
302 | " https://cdn.sofifa.org/flags/52.png | \n",
303 | " 94 | \n",
304 | " 94 | \n",
305 | " FC Barcelona | \n",
306 | " ... | \n",
307 | " 96.0 | \n",
308 | " 33.0 | \n",
309 | " 28.0 | \n",
310 | " 26.0 | \n",
311 | " 6.0 | \n",
312 | " 11.0 | \n",
313 | " 15.0 | \n",
314 | " 14.0 | \n",
315 | " 8.0 | \n",
316 | " €226.5M | \n",
317 | "
\n",
318 | " \n",
319 | " 1 | \n",
320 | " 1 | \n",
321 | " 20801 | \n",
322 | " Cristiano Ronaldo | \n",
323 | " 33 | \n",
324 | " https://cdn.sofifa.org/players/4/19/20801.png | \n",
325 | " Portugal | \n",
326 | " https://cdn.sofifa.org/flags/38.png | \n",
327 | " 94 | \n",
328 | " 94 | \n",
329 | " Juventus | \n",
330 | " ... | \n",
331 | " 95.0 | \n",
332 | " 28.0 | \n",
333 | " 31.0 | \n",
334 | " 23.0 | \n",
335 | " 7.0 | \n",
336 | " 11.0 | \n",
337 | " 15.0 | \n",
338 | " 14.0 | \n",
339 | " 11.0 | \n",
340 | " €127.1M | \n",
341 | "
\n",
342 | " \n",
343 | " 2 | \n",
344 | " 2 | \n",
345 | " 190871 | \n",
346 | " Neymar Jr | \n",
347 | " 26 | \n",
348 | " https://cdn.sofifa.org/players/4/19/190871.png | \n",
349 | " Brazil | \n",
350 | " https://cdn.sofifa.org/flags/54.png | \n",
351 | " 92 | \n",
352 | " 93 | \n",
353 | " Paris Saint-Germain | \n",
354 | " ... | \n",
355 | " 94.0 | \n",
356 | " 27.0 | \n",
357 | " 24.0 | \n",
358 | " 33.0 | \n",
359 | " 9.0 | \n",
360 | " 9.0 | \n",
361 | " 15.0 | \n",
362 | " 15.0 | \n",
363 | " 11.0 | \n",
364 | " €228.1M | \n",
365 | "
\n",
366 | " \n",
367 | " 3 | \n",
368 | " 3 | \n",
369 | " 193080 | \n",
370 | " De Gea | \n",
371 | " 27 | \n",
372 | " https://cdn.sofifa.org/players/4/19/193080.png | \n",
373 | " Spain | \n",
374 | " https://cdn.sofifa.org/flags/45.png | \n",
375 | " 91 | \n",
376 | " 93 | \n",
377 | " Manchester United | \n",
378 | " ... | \n",
379 | " 68.0 | \n",
380 | " 15.0 | \n",
381 | " 21.0 | \n",
382 | " 13.0 | \n",
383 | " 90.0 | \n",
384 | " 85.0 | \n",
385 | " 87.0 | \n",
386 | " 88.0 | \n",
387 | " 94.0 | \n",
388 | " €138.6M | \n",
389 | "
\n",
390 | " \n",
391 | " 4 | \n",
392 | " 4 | \n",
393 | " 192985 | \n",
394 | " K. De Bruyne | \n",
395 | " 27 | \n",
396 | " https://cdn.sofifa.org/players/4/19/192985.png | \n",
397 | " Belgium | \n",
398 | " https://cdn.sofifa.org/flags/7.png | \n",
399 | " 91 | \n",
400 | " 92 | \n",
401 | " Manchester City | \n",
402 | " ... | \n",
403 | " 88.0 | \n",
404 | " 68.0 | \n",
405 | " 58.0 | \n",
406 | " 51.0 | \n",
407 | " 15.0 | \n",
408 | " 13.0 | \n",
409 | " 5.0 | \n",
410 | " 10.0 | \n",
411 | " 13.0 | \n",
412 | " €196.4M | \n",
413 | "
\n",
414 | " \n",
415 | "
\n",
416 | "
5 rows × 89 columns
\n",
417 | "
"
418 | ],
419 | "text/plain": [
420 | " Unnamed: 0 ID Name Age \\\n",
421 | "0 0 158023 L. Messi 31 \n",
422 | "1 1 20801 Cristiano Ronaldo 33 \n",
423 | "2 2 190871 Neymar Jr 26 \n",
424 | "3 3 193080 De Gea 27 \n",
425 | "4 4 192985 K. De Bruyne 27 \n",
426 | "\n",
427 | " Photo Nationality \\\n",
428 | "0 https://cdn.sofifa.org/players/4/19/158023.png Argentina \n",
429 | "1 https://cdn.sofifa.org/players/4/19/20801.png Portugal \n",
430 | "2 https://cdn.sofifa.org/players/4/19/190871.png Brazil \n",
431 | "3 https://cdn.sofifa.org/players/4/19/193080.png Spain \n",
432 | "4 https://cdn.sofifa.org/players/4/19/192985.png Belgium \n",
433 | "\n",
434 | " Flag Overall Potential \\\n",
435 | "0 https://cdn.sofifa.org/flags/52.png 94 94 \n",
436 | "1 https://cdn.sofifa.org/flags/38.png 94 94 \n",
437 | "2 https://cdn.sofifa.org/flags/54.png 92 93 \n",
438 | "3 https://cdn.sofifa.org/flags/45.png 91 93 \n",
439 | "4 https://cdn.sofifa.org/flags/7.png 91 92 \n",
440 | "\n",
441 | " Club ... Composure Marking StandingTackle SlidingTackle \\\n",
442 | "0 FC Barcelona ... 96.0 33.0 28.0 26.0 \n",
443 | "1 Juventus ... 95.0 28.0 31.0 23.0 \n",
444 | "2 Paris Saint-Germain ... 94.0 27.0 24.0 33.0 \n",
445 | "3 Manchester United ... 68.0 15.0 21.0 13.0 \n",
446 | "4 Manchester City ... 88.0 68.0 58.0 51.0 \n",
447 | "\n",
448 | " GKDiving GKHandling GKKicking GKPositioning GKReflexes Release Clause \n",
449 | "0 6.0 11.0 15.0 14.0 8.0 €226.5M \n",
450 | "1 7.0 11.0 15.0 14.0 11.0 €127.1M \n",
451 | "2 9.0 9.0 15.0 15.0 11.0 €228.1M \n",
452 | "3 90.0 85.0 87.0 88.0 94.0 €138.6M \n",
453 | "4 15.0 13.0 5.0 10.0 13.0 €196.4M \n",
454 | "\n",
455 | "[5 rows x 89 columns]"
456 | ]
457 | },
458 | "execution_count": 2,
459 | "metadata": {},
460 | "output_type": "execute_result"
461 | }
462 | ],
463 | "source": [
464 | "fifa = pd.read_csv('fifa_data.csv')\n",
465 | "\n",
466 | "fifa.head(5)"
467 | ]
468 | },
469 | {
470 | "cell_type": "markdown",
471 | "metadata": {},
472 | "source": [
473 | "### Histogram"
474 | ]
475 | },
476 | {
477 | "cell_type": "code",
478 | "execution_count": null,
479 | "metadata": {
480 | "ExecuteTime": {
481 | "end_time": "2021-07-04T12:30:53.151909Z",
482 | "start_time": "2021-07-04T12:30:51.834036Z"
483 | }
484 | },
485 | "outputs": [],
486 | "source": [
487 | "bins = [40,50,60,70,80,90,100]\n",
488 | "\n",
489 | "plt.figure(figsize=(8,5))\n",
490 | "\n",
491 | "plt.hist(fifa.Overall, bins=bins, color='#abcdef')\n",
492 | "\n",
493 | "plt.xticks(bins)\n",
494 | "\n",
495 | "plt.ylabel('Number of Players')\n",
496 | "plt.xlabel('Skill Level')\n",
497 | "plt.title('Distribution of Player Skills in FIFA 2018')\n",
498 | "\n",
499 | "plt.savefig('histogram.png', dpi=300)\n",
500 | "\n",
501 | "plt.show()"
502 | ]
503 | },
504 | {
505 | "cell_type": "markdown",
506 | "metadata": {},
507 | "source": [
508 | "The histogram should look like this:\n",
509 | "\n",
510 | "

\n",
511 | "
"
512 | ]
513 | },
514 | {
515 | "cell_type": "markdown",
516 | "metadata": {},
517 | "source": [
518 | "### Pie Chart"
519 | ]
520 | },
521 | {
522 | "cell_type": "markdown",
523 | "metadata": {},
524 | "source": [
525 | "#### Pie Chart #1"
526 | ]
527 | },
528 | {
529 | "cell_type": "code",
530 | "execution_count": null,
531 | "metadata": {
532 | "ExecuteTime": {
533 | "end_time": "2021-07-04T12:30:53.536672Z",
534 | "start_time": "2021-07-04T12:30:53.161675Z"
535 | }
536 | },
537 | "outputs": [],
538 | "source": [
539 | "left = fifa.loc[fifa['Preferred Foot'] == 'Left'].count()[0]\n",
540 | "right = fifa.loc[fifa['Preferred Foot'] == 'Right'].count()[0]\n",
541 | "\n",
542 | "plt.figure(figsize=(8,5))\n",
543 | "\n",
544 | "labels = ['Left', 'Right']\n",
545 | "colors = ['#abcdef', '#aabbcc']\n",
546 | "\n",
547 | "plt.pie([left, right], labels = labels, colors=colors, autopct='%.2f %%')\n",
548 | "\n",
549 | "plt.title('Foot Preference of FIFA Players')\n",
550 | "\n",
551 | "plt.show()"
552 | ]
553 | },
554 | {
555 | "cell_type": "markdown",
556 | "metadata": {},
557 | "source": [
558 | "The piechart should look like this:\n",
559 | "\n",
560 | "

\n",
561 | "
"
562 | ]
563 | },
564 | {
565 | "cell_type": "markdown",
566 | "metadata": {},
567 | "source": [
568 | "#### Pie Chart #2"
569 | ]
570 | },
571 | {
572 | "cell_type": "code",
573 | "execution_count": null,
574 | "metadata": {
575 | "ExecuteTime": {
576 | "end_time": "2021-07-04T12:30:54.220755Z",
577 | "start_time": "2021-07-04T12:30:53.542534Z"
578 | }
579 | },
580 | "outputs": [],
581 | "source": [
582 | "plt.figure(figsize=(8,5), dpi=100)\n",
583 | "\n",
584 | "plt.style.use('ggplot')\n",
585 | "\n",
586 | "fifa.Weight = [int(x.strip('lbs')) if type(x)==str else x for x in fifa.Weight]\n",
587 | "\n",
588 | "light = fifa.loc[fifa.Weight < 125].count()[0]\n",
589 | "light_medium = fifa[(fifa.Weight >= 125) & (fifa.Weight < 150)].count()[0]\n",
590 | "medium = fifa[(fifa.Weight >= 150) & (fifa.Weight < 175)].count()[0]\n",
591 | "medium_heavy = fifa[(fifa.Weight >= 175) & (fifa.Weight < 200)].count()[0]\n",
592 | "heavy = fifa[fifa.Weight >= 200].count()[0]\n",
593 | "\n",
594 | "weights = [light,light_medium, medium, medium_heavy, heavy]\n",
595 | "label = ['under 125', '125-150', '150-175', '175-200', 'over 200']\n",
596 | "explode = (.4,.2,0,0,.4)\n",
597 | "\n",
598 | "plt.title('Weight of Professional Soccer Players (lbs)')\n",
599 | "\n",
600 | "plt.pie(weights, labels=label, explode=explode, pctdistance=0.8,autopct='%.2f %%')\n",
601 | "plt.show()"
602 | ]
603 | },
604 | {
605 | "cell_type": "markdown",
606 | "metadata": {},
607 | "source": [
608 | "The piechart should look like this:\n",
609 | "\n",
610 | "

\n",
611 | "
"
612 | ]
613 | },
614 | {
615 | "cell_type": "markdown",
616 | "metadata": {},
617 | "source": [
618 | "#### Pie Chart #3"
619 | ]
620 | },
621 | {
622 | "cell_type": "code",
623 | "execution_count": 3,
624 | "metadata": {
625 | "ExecuteTime": {
626 | "end_time": "2021-07-04T12:44:38.377634Z",
627 | "start_time": "2021-07-04T12:44:38.353221Z"
628 | }
629 | },
630 | "outputs": [
631 | {
632 | "data": {
633 | "text/html": [
634 | "\n",
635 | "\n",
648 | "
\n",
649 | " \n",
650 | " \n",
651 | " | \n",
652 | " Id | \n",
653 | " SepalLengthCm | \n",
654 | " SepalWidthCm | \n",
655 | " PetalLengthCm | \n",
656 | " PetalWidthCm | \n",
657 | " Species | \n",
658 | "
\n",
659 | " \n",
660 | " \n",
661 | " \n",
662 | " 0 | \n",
663 | " 1 | \n",
664 | " 5.1 | \n",
665 | " 3.5 | \n",
666 | " 1.4 | \n",
667 | " 0.2 | \n",
668 | " Iris-setosa | \n",
669 | "
\n",
670 | " \n",
671 | " 1 | \n",
672 | " 2 | \n",
673 | " 4.9 | \n",
674 | " 3.0 | \n",
675 | " 1.4 | \n",
676 | " 0.2 | \n",
677 | " Iris-setosa | \n",
678 | "
\n",
679 | " \n",
680 | " 2 | \n",
681 | " 3 | \n",
682 | " 4.7 | \n",
683 | " 3.2 | \n",
684 | " 1.3 | \n",
685 | " 0.2 | \n",
686 | " Iris-setosa | \n",
687 | "
\n",
688 | " \n",
689 | " 3 | \n",
690 | " 4 | \n",
691 | " 4.6 | \n",
692 | " 3.1 | \n",
693 | " 1.5 | \n",
694 | " 0.2 | \n",
695 | " Iris-setosa | \n",
696 | "
\n",
697 | " \n",
698 | " 4 | \n",
699 | " 5 | \n",
700 | " 5.0 | \n",
701 | " 3.6 | \n",
702 | " 1.4 | \n",
703 | " 0.2 | \n",
704 | " Iris-setosa | \n",
705 | "
\n",
706 | " \n",
707 | "
\n",
708 | "
"
709 | ],
710 | "text/plain": [
711 | " Id SepalLengthCm SepalWidthCm PetalLengthCm PetalWidthCm Species\n",
712 | "0 1 5.1 3.5 1.4 0.2 Iris-setosa\n",
713 | "1 2 4.9 3.0 1.4 0.2 Iris-setosa\n",
714 | "2 3 4.7 3.2 1.3 0.2 Iris-setosa\n",
715 | "3 4 4.6 3.1 1.5 0.2 Iris-setosa\n",
716 | "4 5 5.0 3.6 1.4 0.2 Iris-setosa"
717 | ]
718 | },
719 | "execution_count": 3,
720 | "metadata": {},
721 | "output_type": "execute_result"
722 | }
723 | ],
724 | "source": [
725 | "import pandas as pd\n",
726 | "data = pd.read_csv(\"iris_data.csv\")\n",
727 | "data.head()"
728 | ]
729 | },
730 | {
731 | "cell_type": "code",
732 | "execution_count": null,
733 | "metadata": {
734 | "ExecuteTime": {
735 | "end_time": "2021-07-04T12:30:57.738331Z",
736 | "start_time": "2021-07-04T12:30:54.329154Z"
737 | }
738 | },
739 | "outputs": [],
740 | "source": [
741 | "SepalLength = data['SepalLengthCm'].value_counts()\n",
742 | "\n",
743 | "# Plot a pie chart\n",
744 | "%matplotlib inline\n",
745 | "from matplotlib import pyplot as plt\n",
746 | "SepalLength.plot(kind='pie', title='Sepal Length', figsize=(9,9))\n",
747 | "plt.legend()\n",
748 | "plt.show()"
749 | ]
750 | },
751 | {
752 | "cell_type": "markdown",
753 | "metadata": {},
754 | "source": [
755 | "The piechart should look like this:\n",
756 | "\n",
757 | "

\n",
758 | "
"
759 | ]
760 | },
761 | {
762 | "cell_type": "markdown",
763 | "metadata": {},
764 | "source": [
765 | "### Box and Whiskers Chart\n",
766 | "\n",
767 | "A box and whisker plot(box plot) *displays the five-number summary of a set of data. The five-number summary is the minimum, first quartile, median, third quartile, and maximum.*"
768 | ]
769 | },
770 | {
771 | "cell_type": "markdown",
772 | "metadata": {},
773 | "source": [
774 | "#### Box plot #1"
775 | ]
776 | },
777 | {
778 | "cell_type": "code",
779 | "execution_count": null,
780 | "metadata": {
781 | "ExecuteTime": {
782 | "end_time": "2021-07-04T12:30:58.134328Z",
783 | "start_time": "2021-07-04T12:30:57.745170Z"
784 | }
785 | },
786 | "outputs": [],
787 | "source": [
788 | "plt.figure(figsize=(5,8), dpi=100)\n",
789 | "\n",
790 | "plt.style.use('default')\n",
791 | "\n",
792 | "barcelona = fifa.loc[fifa.Club == \"FC Barcelona\"]['Overall']\n",
793 | "madrid = fifa.loc[fifa.Club == \"Real Madrid\"]['Overall']\n",
794 | "revs = fifa.loc[fifa.Club == \"New England Revolution\"]['Overall']\n",
795 | "\n",
796 | "#bp = plt.boxplot([barcelona, madrid, revs], labels=['a','b','c'], boxprops=dict(facecolor='red'))\n",
797 | "bp = plt.boxplot([barcelona, madrid, revs], labels=['FC Barcelona','Real Madrid','NE Revolution'], patch_artist=True, medianprops={'linewidth': 2})\n",
798 | "\n",
799 | "plt.title('Professional Soccer Team Comparison')\n",
800 | "plt.ylabel('FIFA Overall Rating')\n",
801 | "\n",
802 | "for box in bp['boxes']:\n",
803 | " # change outline color\n",
804 | " box.set(color='#4286f4', linewidth=2)\n",
805 | " # change fill color\n",
806 | " box.set(facecolor = '#e0e0e0' )\n",
807 | " # change hatch\n",
808 | " #box.set(hatch = '/')\n",
809 | " \n",
810 | "plt.show()"
811 | ]
812 | },
813 | {
814 | "cell_type": "markdown",
815 | "metadata": {},
816 | "source": [
817 | "The box plot should look like this:\n",
818 | "\n",
819 | "

\n",
820 | "
"
821 | ]
822 | },
823 | {
824 | "cell_type": "markdown",
825 | "metadata": {},
826 | "source": [
827 | "#### Box plot #2"
828 | ]
829 | },
830 | {
831 | "cell_type": "code",
832 | "execution_count": 4,
833 | "metadata": {
834 | "ExecuteTime": {
835 | "end_time": "2021-07-04T12:44:46.874699Z",
836 | "start_time": "2021-07-04T12:44:46.856146Z"
837 | }
838 | },
839 | "outputs": [
840 | {
841 | "name": "stdout",
842 | "output_type": "stream",
843 | "text": [
844 | " Name Salary Hours Grade\n",
845 | "0 John 60000 41 50\n",
846 | "1 Rad 64000 40 50\n",
847 | "2 Var 60000 36 46\n",
848 | "3 Mathew 289000 30 95\n",
849 | "4 Alina 66000 35 50\n",
850 | "5 Lee 50000 39 5\n",
851 | "6 Rogers 60000 40 57\n"
852 | ]
853 | }
854 | ],
855 | "source": [
856 | "#cateating data\n",
857 | "import pandas as pd\n",
858 | "df = pd.DataFrame({'Name': ['John', 'Rad', 'Var', 'Mathew', 'Alina', 'Lee', 'Rogers'],\n",
859 | " 'Salary':[60000,64000,60000,289000,66000,50000,60000],\n",
860 | " 'Hours':[41,40,36,30,35,39,40],\n",
861 | " 'Grade':[50,50,46,95,50,5,57]})\n",
862 | "print(df)"
863 | ]
864 | },
865 | {
866 | "cell_type": "code",
867 | "execution_count": 5,
868 | "metadata": {
869 | "ExecuteTime": {
870 | "end_time": "2021-07-04T12:44:53.560730Z",
871 | "start_time": "2021-07-04T12:44:53.537293Z"
872 | }
873 | },
874 | "outputs": [
875 | {
876 | "name": "stdout",
877 | "output_type": "stream",
878 | "text": [
879 | "0.25 35.5\n",
880 | "0.50 39.0\n",
881 | "0.75 40.0\n",
882 | "Name: Hours, dtype: float64\n"
883 | ]
884 | }
885 | ],
886 | "source": [
887 | "# Quartiles of Hours\n",
888 | "print(df['Hours'].quantile([0.25, 0.5, 0.75]))"
889 | ]
890 | },
891 | {
892 | "cell_type": "code",
893 | "execution_count": null,
894 | "metadata": {
895 | "ExecuteTime": {
896 | "end_time": "2021-07-04T12:30:58.755910Z",
897 | "start_time": "2021-07-04T12:30:58.341361Z"
898 | }
899 | },
900 | "outputs": [],
901 | "source": [
902 | "# Plot a box-whisker chart\n",
903 | "import matplotlib.pyplot as plt\n",
904 | "df['Hours'].plot(kind='box', title='Weekly Hours Distribution', figsize=(10,8))\n",
905 | "plt.show()"
906 | ]
907 | },
908 | {
909 | "cell_type": "markdown",
910 | "metadata": {},
911 | "source": [
912 | "The box plot should look like this:\n",
913 | "\n",
914 | "

\n",
915 | "
"
916 | ]
917 | },
918 | {
919 | "cell_type": "code",
920 | "execution_count": 6,
921 | "metadata": {
922 | "ExecuteTime": {
923 | "end_time": "2021-07-04T12:44:57.581721Z",
924 | "start_time": "2021-07-04T12:44:57.561215Z"
925 | }
926 | },
927 | "outputs": [
928 | {
929 | "name": "stdout",
930 | "output_type": "stream",
931 | "text": [
932 | "0.25 60000.0\n",
933 | "0.50 60000.0\n",
934 | "0.75 65000.0\n",
935 | "Name: Salary, dtype: float64\n"
936 | ]
937 | }
938 | ],
939 | "source": [
940 | "# Quartiles of Salary\n",
941 | "print(df['Salary'].quantile([0.25, 0.5, 0.75]))"
942 | ]
943 | },
944 | {
945 | "cell_type": "code",
946 | "execution_count": null,
947 | "metadata": {
948 | "ExecuteTime": {
949 | "end_time": "2021-07-04T12:30:59.252980Z",
950 | "start_time": "2021-07-04T12:30:58.796927Z"
951 | }
952 | },
953 | "outputs": [],
954 | "source": [
955 | "# Plot a box-whisker chart\n",
956 | "df['Salary'].plot(kind='box', title='Salary Distribution', figsize=(10,8))\n",
957 | "plt.show()"
958 | ]
959 | },
960 | {
961 | "cell_type": "markdown",
962 | "metadata": {},
963 | "source": [
964 | "The box plot should look like this:\n",
965 | "\n",
966 | "

\n",
967 | "
"
968 | ]
969 | },
970 | {
971 | "cell_type": "code",
972 | "execution_count": null,
973 | "metadata": {},
974 | "outputs": [],
975 | "source": []
976 | }
977 | ],
978 | "metadata": {
979 | "hide_input": false,
980 | "kernelspec": {
981 | "display_name": "Python 3",
982 | "language": "python",
983 | "name": "python3"
984 | },
985 | "language_info": {
986 | "codemirror_mode": {
987 | "name": "ipython",
988 | "version": 3
989 | },
990 | "file_extension": ".py",
991 | "mimetype": "text/x-python",
992 | "name": "python",
993 | "nbconvert_exporter": "python",
994 | "pygments_lexer": "ipython3",
995 | "version": "3.8.8"
996 | },
997 | "toc": {
998 | "base_numbering": 1,
999 | "nav_menu": {},
1000 | "number_sections": true,
1001 | "sideBar": true,
1002 | "skip_h1_title": false,
1003 | "title_cell": "Table of Contents",
1004 | "title_sidebar": "Contents",
1005 | "toc_cell": false,
1006 | "toc_position": {},
1007 | "toc_section_display": true,
1008 | "toc_window_display": false
1009 | },
1010 | "varInspector": {
1011 | "cols": {
1012 | "lenName": 16,
1013 | "lenType": 16,
1014 | "lenVar": 40
1015 | },
1016 | "kernels_config": {
1017 | "python": {
1018 | "delete_cmd_postfix": "",
1019 | "delete_cmd_prefix": "del ",
1020 | "library": "var_list.py",
1021 | "varRefreshCmd": "print(var_dic_list())"
1022 | },
1023 | "r": {
1024 | "delete_cmd_postfix": ") ",
1025 | "delete_cmd_prefix": "rm(",
1026 | "library": "var_list.r",
1027 | "varRefreshCmd": "cat(var_dic_list()) "
1028 | }
1029 | },
1030 | "types_to_exclude": [
1031 | "module",
1032 | "function",
1033 | "builtin_function_or_method",
1034 | "instance",
1035 | "_Feature"
1036 | ],
1037 | "window_display": false
1038 | }
1039 | },
1040 | "nbformat": 4,
1041 | "nbformat_minor": 2
1042 | }
1043 |
--------------------------------------------------------------------------------
/003_Python_Matplotlib_Exercise_2.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "\n",
8 | "All the IPython Notebooks in this lecture series by Dr. Milan Parmar are available @ **[GitHub](https://github.com/milaan9/11_Python_Matplotlib_Module)**\n",
9 | ""
10 | ]
11 | },
12 | {
13 | "cell_type": "markdown",
14 | "metadata": {},
15 | "source": [
16 | "# Python Matplotlib\n",
17 | "\n",
18 | "**[Matplotlib](http://www.numpy.org/)** is a Python 2D plotting library that produces high-quality charts and figures, which helps us visualize extensive data to understand better. Pandas is a handy and useful data-structure tool for analyzing large and complex data."
19 | ]
20 | },
21 | {
22 | "cell_type": "markdown",
23 | "metadata": {},
24 | "source": [
25 | "In this exercise, we are using Pandas and Matplotlib to visualize **Company Sales Data**. You can download data from my Github (**[company_sales_data.csv](https://github.com/milaan9/11_Python_Matplotlib_Module/blob/main/company_sales_data.csv)**).\n",
26 | "\n",
27 | "Use the following CSV file for this exercise. Read this file using Pandas or NumPy or using in-built matplotlib function."
28 | ]
29 | },
30 | {
31 | "cell_type": "markdown",
32 | "metadata": {},
33 | "source": [
34 | "**What included in this Matplotlib Exercise?**\n",
35 | "\n",
36 | "This exercise contains ten questions. The solution is provided for each issue. Each question includes a specific Matplotlib topic you need to learn. When you complete each question, you get more familiar with Data data visualization using matplotlib."
37 | ]
38 | },
39 | {
40 | "cell_type": "markdown",
41 | "metadata": {},
42 | "source": [
43 | "## Exercise 1: Read Total profit of all months and show it using a line plot\n",
44 | "\n",
45 | "Total profit data provided for each month. Generated line plot must include the following properties: \n",
46 | "\n",
47 | "* X label name = Month Number\n",
48 | "* Y label name = Total profit\n",
49 | "\n",
50 | "The line plot graph should look like this:\n",
51 | "\n",
52 | "

\n",
53 | "
"
54 | ]
55 | },
56 | {
57 | "cell_type": "code",
58 | "execution_count": null,
59 | "metadata": {
60 | "ExecuteTime": {
61 | "end_time": "2021-06-15T05:47:22.088430Z",
62 | "start_time": "2021-06-15T05:47:19.123610Z"
63 | }
64 | },
65 | "outputs": [],
66 | "source": [
67 | "import pandas as pd\n",
68 | "import matplotlib.pyplot as plt \n",
69 | "\n",
70 | "#df = pd.read_csv(\"C:\\\\Users\\\\Milaan\\\\01_Learn_Python4Data\\\\11_Python_Matplotlib_Module\\\\company_sales_data.csv\")\n",
71 | "df = pd.read_csv('company_sales_data.csv')\n",
72 | "profitList = df ['total_profit'].tolist()\n",
73 | "monthList = df ['month_number'].tolist()\n",
74 | "plt.plot(monthList, profitList, label = 'Month-wise Profit data of last year')\n",
75 | "plt.xlabel('Month number')\n",
76 | "plt.ylabel('Profit in dollar')\n",
77 | "plt.xticks(monthList)\n",
78 | "plt.title('Company profit per month')\n",
79 | "plt.yticks([100000, 200000, 300000, 400000, 500000])\n",
80 | "plt.show()"
81 | ]
82 | },
83 | {
84 | "cell_type": "markdown",
85 | "metadata": {},
86 | "source": [
87 | "## Exercise 2: Get total profit of all months and show line plot with the following Style properties\n",
88 | "\n",
89 | "Generated line plot must include following Style properties:\n",
90 | "\n",
91 | "* Line Style dotted and Line-color should be red\n",
92 | "* Show legend at the lower right location.\n",
93 | "* X label name = Month Number\n",
94 | "* Y label name = Sold units number\n",
95 | "* Add a circle marker.\n",
96 | "* Line marker color as read\n",
97 | "* Line width should be 3\n",
98 | "\n",
99 | "The line plot graph should look like this:\n",
100 | "\n",
101 | "

\n",
102 | "
"
103 | ]
104 | },
105 | {
106 | "cell_type": "code",
107 | "execution_count": null,
108 | "metadata": {
109 | "ExecuteTime": {
110 | "end_time": "2021-06-15T05:47:22.629443Z",
111 | "start_time": "2021-06-15T05:47:22.097710Z"
112 | }
113 | },
114 | "outputs": [],
115 | "source": [
116 | "import pandas as pd\n",
117 | "import matplotlib.pyplot as plt \n",
118 | "\n",
119 | "df = pd.read_csv('company_sales_data.csv')\n",
120 | "profitList = df ['total_profit'].tolist()\n",
121 | "monthList = df ['month_number'].tolist()\n",
122 | "\n",
123 | "plt.plot(monthList, profitList, label = 'Profit data of last year', \n",
124 | " color='r', marker='o', markerfacecolor='k', \n",
125 | " linestyle='--', linewidth=3)\n",
126 | " \n",
127 | "plt.xlabel('Month Number')\n",
128 | "plt.ylabel('Profit in dollar')\n",
129 | "plt.legend(loc='lower right')\n",
130 | "plt.title('Company Sales data of last year')\n",
131 | "plt.xticks(monthList)\n",
132 | "plt.yticks([100000, 200000, 300000, 400000, 500000])\n",
133 | "plt.show()"
134 | ]
135 | },
136 | {
137 | "cell_type": "markdown",
138 | "metadata": {},
139 | "source": [
140 | "## Exercise 3: Read all product sales data and show it using a multiline plot\n",
141 | "\n",
142 | "Display the number of units sold per month for each product using multiline plots. (i.e., Separate Plotline for each product ).\n",
143 | "\n",
144 | "The graph should look like this:\n",
145 | "\n",
146 | "

\n",
147 | "
"
148 | ]
149 | },
150 | {
151 | "cell_type": "code",
152 | "execution_count": null,
153 | "metadata": {
154 | "ExecuteTime": {
155 | "end_time": "2021-06-15T05:47:23.313034Z",
156 | "start_time": "2021-06-15T05:47:22.633352Z"
157 | }
158 | },
159 | "outputs": [],
160 | "source": [
161 | "import pandas as pd\n",
162 | "import matplotlib.pyplot as plt \n",
163 | "\n",
164 | "df = pd.read_csv('company_sales_data.csv')\n",
165 | "monthList = df ['month_number'].tolist()\n",
166 | "faceCremSalesData = df ['facecream'].tolist()\n",
167 | "faceWashSalesData = df ['facewash'].tolist()\n",
168 | "toothPasteSalesData = df ['toothpaste'].tolist()\n",
169 | "bathingsoapSalesData = df ['bathingsoap'].tolist()\n",
170 | "shampooSalesData = df ['shampoo'].tolist()\n",
171 | "moisturizerSalesData = df ['moisturizer'].tolist()\n",
172 | "\n",
173 | "plt.plot(monthList, faceCremSalesData, label = 'Face cream Sales Data', marker='o', linewidth=3)\n",
174 | "plt.plot(monthList, faceWashSalesData, label = 'Face Wash Sales Data', marker='o', linewidth=3)\n",
175 | "plt.plot(monthList, toothPasteSalesData, label = 'ToothPaste Sales Data', marker='o', linewidth=3)\n",
176 | "plt.plot(monthList, bathingsoapSalesData, label = 'ToothPaste Sales Data', marker='o', linewidth=3)\n",
177 | "plt.plot(monthList, shampooSalesData, label = 'ToothPaste Sales Data', marker='o', linewidth=3)\n",
178 | "plt.plot(monthList, moisturizerSalesData, label = 'ToothPaste Sales Data', marker='o', linewidth=3)\n",
179 | "\n",
180 | "plt.xlabel('Month Number')\n",
181 | "plt.ylabel('Sales units in number')\n",
182 | "plt.legend(loc='upper left')\n",
183 | "plt.xticks(monthList)\n",
184 | "plt.yticks([1000, 2000, 4000, 6000, 8000, 10000, 12000, 15000, 18000])\n",
185 | "plt.title('Sales data')\n",
186 | "plt.show()"
187 | ]
188 | },
189 | {
190 | "cell_type": "markdown",
191 | "metadata": {},
192 | "source": [
193 | "## Exercise 4: Read toothpaste sales data of each month and show it using a scatter plot\n",
194 | "\n",
195 | "Also, add a grid in the plot. gridline style should **–**.\n",
196 | "\n",
197 | "The scatter plot should look like this:\n",
198 | "\n",
199 | "

\n",
200 | "
"
201 | ]
202 | },
203 | {
204 | "cell_type": "code",
205 | "execution_count": null,
206 | "metadata": {
207 | "ExecuteTime": {
208 | "end_time": "2021-06-15T05:47:24.059615Z",
209 | "start_time": "2021-06-15T05:47:23.322800Z"
210 | }
211 | },
212 | "outputs": [],
213 | "source": [
214 | "import pandas as pd\n",
215 | "import matplotlib.pyplot as plt \n",
216 | "\n",
217 | "df = pd.read_csv('company_sales_data.csv')\n",
218 | "monthList = df ['month_number'].tolist()\n",
219 | "toothPasteSalesData = df ['toothpaste'].tolist()\n",
220 | "plt.scatter(monthList, toothPasteSalesData, label = 'Tooth paste Sales data')\n",
221 | "plt.xlabel('Month Number')\n",
222 | "plt.ylabel('Number of units Sold')\n",
223 | "plt.legend(loc='upper left')\n",
224 | "plt.title(' Tooth paste Sales data')\n",
225 | "plt.xticks(monthList)\n",
226 | "plt.grid(True, linewidth= 1, linestyle=\"--\")\n",
227 | "plt.show()"
228 | ]
229 | },
230 | {
231 | "cell_type": "markdown",
232 | "metadata": {},
233 | "source": [
234 | "## Exercise 5: Read face cream and facewash product sales data and show it using the bar chart\n",
235 | "\n",
236 | "The bar chart should display the number of units sold per month for each product. Add a separate bar for each product in the same chart.\n",
237 | "\n",
238 | "The bar chart should look like this:\n",
239 | "\n",
240 | "

\n",
241 | "
"
242 | ]
243 | },
244 | {
245 | "cell_type": "code",
246 | "execution_count": null,
247 | "metadata": {
248 | "ExecuteTime": {
249 | "end_time": "2021-06-15T05:47:24.942417Z",
250 | "start_time": "2021-06-15T05:47:24.067424Z"
251 | }
252 | },
253 | "outputs": [],
254 | "source": [
255 | "import pandas as pd\n",
256 | "import matplotlib.pyplot as plt \n",
257 | "\n",
258 | "df = pd.read_csv('company_sales_data.csv')\n",
259 | "monthList = df ['month_number'].tolist()\n",
260 | "faceCremSalesData = df ['facecream'].tolist()\n",
261 | "faceWashSalesData = df ['facewash'].tolist()\n",
262 | "\n",
263 | "plt.bar([a-0.25 for a in monthList], faceCremSalesData, width= 0.25, label = 'Face Cream sales data', align='edge')\n",
264 | "plt.bar([a+0.25 for a in monthList], faceWashSalesData, width= -0.25, label = 'Face Wash sales data', align='edge')\n",
265 | "plt.xlabel('Month Number')\n",
266 | "plt.ylabel('Sales units in number')\n",
267 | "plt.legend(loc='upper left')\n",
268 | "plt.title(' Sales data')\n",
269 | "\n",
270 | "plt.xticks(monthList)\n",
271 | "plt.grid(True, linewidth= 1, linestyle=\"--\")\n",
272 | "plt.title('Facewash and facecream sales data')\n",
273 | "plt.show()"
274 | ]
275 | },
276 | {
277 | "cell_type": "markdown",
278 | "metadata": {},
279 | "source": [
280 | "## Exercise 6: Read sales data of bathing soap of all months and show it using a bar chart. Save this plot to your hard disk\n",
281 | "\n",
282 | "The bar chart should look like this:\n",
283 | "\n",
284 | "

\n",
285 | "
"
286 | ]
287 | },
288 | {
289 | "cell_type": "code",
290 | "execution_count": null,
291 | "metadata": {
292 | "ExecuteTime": {
293 | "end_time": "2021-06-15T05:47:26.311549Z",
294 | "start_time": "2021-06-15T05:47:24.945350Z"
295 | }
296 | },
297 | "outputs": [],
298 | "source": [
299 | "import pandas as pd\n",
300 | "import matplotlib.pyplot as plt \n",
301 | "\n",
302 | "df = pd.read_csv('company_sales_data.csv')\n",
303 | "monthList = df ['month_number'].tolist()\n",
304 | "bathingsoapSalesData = df ['bathingsoap'].tolist()\n",
305 | "plt.bar(monthList, bathingsoapSalesData)\n",
306 | "plt.xlabel('Month Number')\n",
307 | "plt.ylabel('Sales units in number')\n",
308 | "plt.title(' Sales data')\n",
309 | "plt.xticks(monthList)\n",
310 | "plt.grid(True, linewidth= 1, linestyle=\"--\")\n",
311 | "plt.title('bathingsoap sales data')\n",
312 | "plt.savefig('D:\\sales_data_of_bathingsoap.png', dpi=150)\n",
313 | "plt.show()"
314 | ]
315 | },
316 | {
317 | "cell_type": "markdown",
318 | "metadata": {},
319 | "source": [
320 | "## Exercise 7: Read the total profit of each month and show it using the histogram to see the most common profit ranges\n",
321 | "\n",
322 | "The histogram should look like this:\n",
323 | "\n",
324 | "

\n",
325 | "
"
326 | ]
327 | },
328 | {
329 | "cell_type": "code",
330 | "execution_count": null,
331 | "metadata": {
332 | "ExecuteTime": {
333 | "end_time": "2021-06-15T05:47:26.840845Z",
334 | "start_time": "2021-06-15T05:47:26.318388Z"
335 | }
336 | },
337 | "outputs": [],
338 | "source": [
339 | "import pandas as pd\n",
340 | "import matplotlib.pyplot as plt \n",
341 | "\n",
342 | "df = pd.read_csv('company_sales_data.csv')\n",
343 | "profitList = df ['total_profit'].tolist()\n",
344 | "labels = ['low', 'average', 'Good', 'Best']\n",
345 | "profit_range = [150000, 175000, 200000, 225000, 250000, 300000, 350000]\n",
346 | "plt.hist(profitList, profit_range, label = 'Profit data')\n",
347 | "plt.xlabel('profit range in dollar')\n",
348 | "plt.ylabel('Actual Profit in dollar')\n",
349 | "plt.legend(loc='upper left')\n",
350 | "plt.xticks(profit_range)\n",
351 | "plt.title('Profit data')\n",
352 | "plt.show()"
353 | ]
354 | },
355 | {
356 | "cell_type": "markdown",
357 | "metadata": {},
358 | "source": [
359 | "## Exercise 8: Calculate total sale data for last year for each product and show it using a Pie chart\n",
360 | "\n",
361 | ">**Note:** In Pie chart display Number of units sold per year for each product in percentage.\n",
362 | "\n",
363 | "The Pie chart should look like this:\n",
364 | "\n",
365 | "

\n",
366 | "
"
367 | ]
368 | },
369 | {
370 | "cell_type": "code",
371 | "execution_count": null,
372 | "metadata": {
373 | "ExecuteTime": {
374 | "end_time": "2021-06-15T05:47:27.416034Z",
375 | "start_time": "2021-06-15T05:47:26.852564Z"
376 | }
377 | },
378 | "outputs": [],
379 | "source": [
380 | "import pandas as pd\n",
381 | "import matplotlib.pyplot as plt \n",
382 | "\n",
383 | "df = pd.read_csv('company_sales_data.csv')\n",
384 | "monthList = df ['month_number'].tolist()\n",
385 | "\n",
386 | "labels = ['FaceCream', 'FaseWash', 'ToothPaste', 'Bathing soap', 'Shampoo', 'Moisturizer']\n",
387 | "salesData = [df ['facecream'].sum(), df ['facewash'].sum(), df ['toothpaste'].sum(), \n",
388 | " df ['bathingsoap'].sum(), df ['shampoo'].sum(), df ['moisturizer'].sum()]\n",
389 | "plt.axis(\"equal\")\n",
390 | "plt.pie(salesData, labels=labels, autopct='%1.1f%%')\n",
391 | "plt.legend(loc='lower right')\n",
392 | "plt.title('Sales data')\n",
393 | "plt.show()"
394 | ]
395 | },
396 | {
397 | "cell_type": "markdown",
398 | "metadata": {},
399 | "source": [
400 | "## Exercise 9: Read Bathing soap facewash of all months and display it using the Subplot\n",
401 | "\n",
402 | "The Subplot should look like this:\n",
403 | "\n",
404 | "

\n",
405 | "
"
406 | ]
407 | },
408 | {
409 | "cell_type": "code",
410 | "execution_count": null,
411 | "metadata": {
412 | "ExecuteTime": {
413 | "end_time": "2021-06-15T05:47:28.203629Z",
414 | "start_time": "2021-06-15T05:47:27.427755Z"
415 | }
416 | },
417 | "outputs": [],
418 | "source": [
419 | "import pandas as pd\n",
420 | "import matplotlib.pyplot as plt \n",
421 | "\n",
422 | "df = pd.read_csv('company_sales_data.csv')\n",
423 | "monthList = df ['month_number'].tolist()\n",
424 | "bathingsoap = df ['bathingsoap'].tolist()\n",
425 | "faceWashSalesData = df ['facewash'].tolist()\n",
426 | "\n",
427 | "f, axarr = plt.subplots(2, sharex=True)\n",
428 | "axarr[0].plot(monthList, bathingsoap, label = 'Bathingsoap Sales Data', color='k', marker='o', linewidth=3)\n",
429 | "axarr[0].set_title('Sales data of a Bathingsoap')\n",
430 | "axarr[1].plot(monthList, faceWashSalesData, label = 'Face Wash Sales Data', color='r', marker='o', linewidth=3)\n",
431 | "axarr[1].set_title('Sales data of a facewash')\n",
432 | "\n",
433 | "plt.xticks(monthList)\n",
434 | "plt.xlabel('Month Number')\n",
435 | "plt.ylabel('Sales units in number')\n",
436 | "plt.show()"
437 | ]
438 | },
439 | {
440 | "cell_type": "markdown",
441 | "metadata": {},
442 | "source": [
443 | "## Exercise Question 10: Read all product sales data and show it using the stack plot\n",
444 | "\n",
445 | "The Stack plot should look like this:\n",
446 | "\n",
447 | "

\n",
448 | "
"
449 | ]
450 | },
451 | {
452 | "cell_type": "code",
453 | "execution_count": null,
454 | "metadata": {
455 | "ExecuteTime": {
456 | "end_time": "2021-06-15T05:47:28.723158Z",
457 | "start_time": "2021-06-15T05:47:28.224629Z"
458 | }
459 | },
460 | "outputs": [],
461 | "source": [
462 | "import pandas as pd\n",
463 | "import matplotlib.pyplot as plt \n",
464 | "\n",
465 | "df = pd.read_csv('company_sales_data.csv')\n",
466 | "monthList = df ['month_number'].tolist()\n",
467 | "\n",
468 | "faceCremSalesData = df ['facecream'].tolist()\n",
469 | "faceWashSalesData = df ['facewash'].tolist()\n",
470 | "toothPasteSalesData = df ['toothpaste'].tolist()\n",
471 | "bathingsoapSalesData = df ['bathingsoap'].tolist()\n",
472 | "shampooSalesData = df ['shampoo'].tolist()\n",
473 | "moisturizerSalesData = df ['moisturizer'].tolist()\n",
474 | "\n",
475 | "plt.plot([],[],color='m', label='face Cream', linewidth=5)\n",
476 | "plt.plot([],[],color='c', label='Face wash', linewidth=5)\n",
477 | "plt.plot([],[],color='r', label='Tooth paste', linewidth=5)\n",
478 | "plt.plot([],[],color='k', label='Bathing soap', linewidth=5)\n",
479 | "plt.plot([],[],color='g', label='Shampoo', linewidth=5)\n",
480 | "plt.plot([],[],color='y', label='Moisturizer', linewidth=5)\n",
481 | "\n",
482 | "plt.stackplot(monthList, faceCremSalesData, faceWashSalesData, toothPasteSalesData, \n",
483 | " bathingsoapSalesData, shampooSalesData, moisturizerSalesData, \n",
484 | " colors=['m','c','r','k','g','y'])\n",
485 | "\n",
486 | "plt.xlabel('Month Number')\n",
487 | "plt.ylabel('Sales unints in Number')\n",
488 | "plt.title('Alll product sales data using stack plot')\n",
489 | "plt.legend(loc='upper left')\n",
490 | "plt.show()"
491 | ]
492 | },
493 | {
494 | "cell_type": "code",
495 | "execution_count": null,
496 | "metadata": {},
497 | "outputs": [],
498 | "source": []
499 | }
500 | ],
501 | "metadata": {
502 | "hide_input": false,
503 | "kernelspec": {
504 | "display_name": "Python 3",
505 | "language": "python",
506 | "name": "python3"
507 | },
508 | "language_info": {
509 | "codemirror_mode": {
510 | "name": "ipython",
511 | "version": 3
512 | },
513 | "file_extension": ".py",
514 | "mimetype": "text/x-python",
515 | "name": "python",
516 | "nbconvert_exporter": "python",
517 | "pygments_lexer": "ipython3",
518 | "version": "3.8.8"
519 | },
520 | "toc": {
521 | "base_numbering": 1,
522 | "nav_menu": {},
523 | "number_sections": true,
524 | "sideBar": true,
525 | "skip_h1_title": false,
526 | "title_cell": "Table of Contents",
527 | "title_sidebar": "Contents",
528 | "toc_cell": false,
529 | "toc_position": {},
530 | "toc_section_display": true,
531 | "toc_window_display": false
532 | },
533 | "varInspector": {
534 | "cols": {
535 | "lenName": 16,
536 | "lenType": 16,
537 | "lenVar": 40
538 | },
539 | "kernels_config": {
540 | "python": {
541 | "delete_cmd_postfix": "",
542 | "delete_cmd_prefix": "del ",
543 | "library": "var_list.py",
544 | "varRefreshCmd": "print(var_dic_list())"
545 | },
546 | "r": {
547 | "delete_cmd_postfix": ") ",
548 | "delete_cmd_prefix": "rm(",
549 | "library": "var_list.r",
550 | "varRefreshCmd": "cat(var_dic_list()) "
551 | }
552 | },
553 | "types_to_exclude": [
554 | "module",
555 | "function",
556 | "builtin_function_or_method",
557 | "instance",
558 | "_Feature"
559 | ],
560 | "window_display": false
561 | }
562 | },
563 | "nbformat": 4,
564 | "nbformat_minor": 2
565 | }
566 |
--------------------------------------------------------------------------------
/Gas_price_figure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/Gas_price_figure.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 milaan9
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Matplotlib Cheat Sheet Plotting in Python.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/Matplotlib Cheat Sheet Plotting in Python.pdf
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | # 11_Python_Matplotlib_Module
24 |
25 | ## Introduction 👋
26 |
27 | **What Is Python Matplotlib?**
28 | matplotlib.pyplot is a plotting library used for 2D graphics in python programming language. It can be used in python scripts, shell, web application servers and other graphical user interface toolkits.
29 |
30 | **What is Matplotlib used for?**
31 | Matploitlib is a Python Library used for plotting, this python library provides and objected-oriented APIs for integrating plots into applications.
32 |
33 | **Is Matplotlib Included in Python?**
34 | Matplotlib is not a part of the Standard Libraries which is installed by default when Python, there are several toolkits which are available that extend python matplotlib functionality. Some of them are separate downloads, others can be shipped with the matplotlib source code but have external dependencies.
35 |
36 | ---
37 |
38 | ## Table of contents 📋
39 |
40 | | **No.** | **Name** |
41 | | ------- | -------- |
42 | | 01 | **[Python_Matplotlib_pyplot](https://github.com/milaan9/11_Python_Matplotlib_Module/blob/main/001_Python_Matplotlib_pyplot.ipynb)** |
43 | | 02 | **[Python_Matplotlib_Exercise_1](https://github.com/milaan9/11_Python_Matplotlib_Module/blob/main/002_Python_Matplotlib_Exercise_1.ipynb)** |
44 | | 03 | **[Python_Matplotlib_Exercise_2](https://github.com/milaan9/11_Python_Matplotlib_Module/blob/main/003_Python_Matplotlib_Exercise_2.ipynb)** |
45 | | | **[gas_prices](https://github.com/milaan9/11_Python_Matplotlib_Module/blob/main/gas_prices.csv)** |
46 | | | **[fifa_data](https://github.com/milaan9/11_Python_Matplotlib_Module/blob/main/fifa_data.csv)** |
47 | | | **[company_sales_data](https://github.com/milaan9/11_Python_Matplotlib_Module/blob/main/company_sales_data.csv)** |
48 | | | **[iris_data](https://github.com/milaan9/11_Python_Matplotlib_Module/blob/main/iris_data.csv)** |
49 | | 04 | **[Matplotlib Cheat Sheet Plotting in Python.pdf](https://github.com/milaan9/11_Python_Matplotlib_Module/blob/main/Matplotlib%20Cheat%20Sheet%20Plotting%20in%20Python.pdf)** |
50 |
51 |
52 | These are online **read-only** versions. However you can **`Run ▶`** all the codes **online** by clicking here ➞
53 |
54 | ---
55 |
56 | ## Install Matplotlib Module:
57 |
58 | Open your [](https://www.anaconda.com/products/individual) Prompt
and type and run the following command (individually):
59 |
60 | - pip install matplotlib
61 |
62 |
63 | Once Installed now we can import it inside our python code.
64 |
65 | ---
66 |
67 | ## Frequently asked questions ❔
68 |
69 | ### How can I thank you for writing and sharing this tutorial? 🌷
70 |
71 | You can
and
Starring and Forking is free for you, but it tells me and other people that it was helpful and you like this tutorial.
72 |
73 | Go [**`here`**](https://github.com/milaan9/11_Python_Matplotlib_Module) if you aren't here already and click ➞ **`✰ Star`** and **`ⵖ Fork`** button in the top right corner. You'll be asked to create a GitHub account if you don't already have one.
74 |
75 | ---
76 |
77 | ### How can I read this tutorial without an Internet connection?
78 |
79 | 1. Go [**`here`**](https://github.com/milaan9/11_Python_Matplotlib_Module) and click the big green ➞ **`Code`** button in the top right of the page, then click ➞ [**`Download ZIP`**](https://github.com/milaan9/11_Python_Matplotlib_Module/archive/refs/heads/main.zip).
80 |
81 | 
82 |
83 | 2. Extract the ZIP and open it. Unfortunately I don't have any more specific instructions because how exactly this is done depends on which operating system you run.
84 |
85 | 3. Launch ipython notebook from the folder which contains the notebooks. Open each one of them
86 |
87 | **`Kernel > Restart & Clear Output`**
88 |
89 | This will clear all the outputs and now you can understand each statement and learn interactively.
90 |
91 | If you have git and you know how to use it, you can also clone the repository instead of downloading a zip and extracting it. An advantage with doing it this way is that you don't need to download the whole tutorial again to get the latest version of it, all you need to do is to pull with git and run ipython notebook again.
92 |
93 | ---
94 |
95 | ## Authors ✍️
96 |
97 | I'm Dr. Milaan Parmar and I have written this tutorial. If you think you can add/correct/edit and enhance this tutorial you are most welcome🙏
98 |
99 | See [github's contributors page](https://github.com/milaan9/11_Python_Matplotlib_Module/graphs/contributors) for details.
100 |
101 | If you have trouble with this tutorial please tell me about it by [Create an issue on GitHub](https://github.com/milaan9/11_Python_Matplotlib_Module/issues/new). and I'll make this tutorial better. This is probably the best choice if you had trouble following the tutorial, and something in it should be explained better. You will be asked to create a GitHub account if you don't already have one.
102 |
103 | If you like this tutorial, please [give it a ⭐ star](https://github.com/milaan9/11_Python_Matplotlib_Module).
104 |
105 | ---
106 |
107 | ## Licence 📜
108 |
109 | You may use this tutorial freely at your own risk. See [LICENSE](./LICENSE).
110 |
--------------------------------------------------------------------------------
/barchart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/barchart.png
--------------------------------------------------------------------------------
/company_sales_data.csv:
--------------------------------------------------------------------------------
1 | month_number,facecream,facewash,toothpaste,bathingsoap,shampoo,moisturizer,total_units,total_profit
2 | 1,2500,1500,5200,9200,1200,1500,21100,211000
3 | 2,2630,1200,5100,6100,2100,1200,18330,183300
4 | 3,2140,1340,4550,9550,3550,1340,22470,224700
5 | 4,3400,1130,5870,8870,1870,1130,22270,222700
6 | 5,3600,1740,4560,7760,1560,1740,20960,209600
7 | 6,2760,1555,4890,7490,1890,1555,20140,201400
8 | 7,2980,1120,4780,8980,1780,1120,29550,295500
9 | 8,3700,1400,5860,9960,2860,1400,36140,361400
10 | 9,3540,1780,6100,8100,2100,1780,23400,234000
11 | 10,1990,1890,8300,10300,2300,1890,26670,266700
12 | 11,2340,2100,7300,13300,2400,2100,41280,412800
13 | 12,2900,1760,7400,14400,1800,1760,30020,300200
14 |
--------------------------------------------------------------------------------
/dnld_rep.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/dnld_rep.png
--------------------------------------------------------------------------------
/gas_prices.csv:
--------------------------------------------------------------------------------
1 | Year,Australia,Canada,France,Germany,Italy,Japan,Mexico,South Korea,UK,USA
2 | 1990,,1.87,3.63,2.65,4.59,3.16,1,2.05,2.82,1.16
3 | 1991,1.96,1.92,3.45,2.9,4.5,3.46,1.3,2.49,3.01,1.14
4 | 1992,1.89,1.73,3.56,3.27,4.53,3.58,1.5,2.65,3.06,1.13
5 | 1993,1.73,1.57,3.41,3.07,3.68,4.16,1.56,2.88,2.84,1.11
6 | 1994,1.84,1.45,3.59,3.52,3.7,4.36,1.48,2.87,2.99,1.11
7 | 1995,1.95,1.53,4.26,3.96,4,4.43,1.11,2.94,3.21,1.15
8 | 1996,2.12,1.61,4.41,3.94,4.39,3.64,1.25,3.18,3.34,1.23
9 | 1997,2.05,1.62,4,3.53,4.07,3.26,1.47,3.34,3.83,1.23
10 | 1998,1.63,1.38,3.87,3.34,3.84,2.82,1.49,3.04,4.06,1.06
11 | 1999,1.72,1.52,3.85,3.42,3.87,3.27,1.79,3.8,4.29,1.17
12 | 2000,1.94,1.86,3.8,3.45,3.77,3.65,2.01,4.18,4.58,1.51
13 | 2001,1.71,1.72,3.51,3.4,3.57,3.27,2.2,3.76,4.13,1.46
14 | 2002,1.76,1.69,3.62,3.67,3.74,3.15,2.24,3.84,4.16,1.36
15 | 2003,2.19,1.99,4.35,4.59,4.53,3.47,2.04,4.11,4.7,1.59
16 | 2004,2.72,2.37,4.99,5.24,5.29,3.93,2.03,4.51,5.56,1.88
17 | 2005,3.23,2.89,5.46,5.66,5.74,4.28,2.22,5.28,5.97,2.3
18 | 2006,3.54,3.26,5.88,6.03,6.1,4.47,2.31,5.92,6.36,2.59
19 | 2007,3.85,3.59,6.6,6.88,6.73,4.49,2.4,6.21,7.13,2.8
20 | 2008,4.45,4.08,7.51,7.75,7.63,5.74,2.45,5.83,7.42,3.27
21 |
--------------------------------------------------------------------------------
/histogram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/histogram.png
--------------------------------------------------------------------------------
/img/dnld_rep.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/dnld_rep.png
--------------------------------------------------------------------------------
/img/ex1_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex1_1.png
--------------------------------------------------------------------------------
/img/ex1_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex1_10.png
--------------------------------------------------------------------------------
/img/ex1_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex1_2.png
--------------------------------------------------------------------------------
/img/ex1_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex1_3.png
--------------------------------------------------------------------------------
/img/ex1_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex1_4.png
--------------------------------------------------------------------------------
/img/ex1_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex1_5.png
--------------------------------------------------------------------------------
/img/ex1_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex1_6.png
--------------------------------------------------------------------------------
/img/ex1_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex1_7.png
--------------------------------------------------------------------------------
/img/ex1_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex1_8.png
--------------------------------------------------------------------------------
/img/ex1_9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex1_9.png
--------------------------------------------------------------------------------
/img/ex2_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex2_1.png
--------------------------------------------------------------------------------
/img/ex2_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex2_10.png
--------------------------------------------------------------------------------
/img/ex2_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex2_2.png
--------------------------------------------------------------------------------
/img/ex2_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex2_3.png
--------------------------------------------------------------------------------
/img/ex2_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex2_4.png
--------------------------------------------------------------------------------
/img/ex2_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex2_5.png
--------------------------------------------------------------------------------
/img/ex2_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex2_6.png
--------------------------------------------------------------------------------
/img/ex2_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex2_7.png
--------------------------------------------------------------------------------
/img/ex2_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex2_8.png
--------------------------------------------------------------------------------
/img/ex2_9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/img/ex2_9.png
--------------------------------------------------------------------------------
/iris_data.csv:
--------------------------------------------------------------------------------
1 | Id,SepalLengthCm,SepalWidthCm,PetalLengthCm,PetalWidthCm,Species
2 | 1,5.1,3.5,1.4,0.2,Iris-setosa
3 | 2,4.9,3.0,1.4,0.2,Iris-setosa
4 | 3,4.7,3.2,1.3,0.2,Iris-setosa
5 | 4,4.6,3.1,1.5,0.2,Iris-setosa
6 | 5,5.0,3.6,1.4,0.2,Iris-setosa
7 | 6,5.4,3.9,1.7,0.4,Iris-setosa
8 | 7,4.6,3.4,1.4,0.3,Iris-setosa
9 | 8,5.0,3.4,1.5,0.2,Iris-setosa
10 | 9,4.4,2.9,1.4,0.2,Iris-setosa
11 | 10,4.9,3.1,1.5,0.1,Iris-setosa
12 | 11,5.4,3.7,1.5,0.2,Iris-setosa
13 | 12,4.8,3.4,1.6,0.2,Iris-setosa
14 | 13,4.8,3.0,1.4,0.1,Iris-setosa
15 | 14,4.3,3.0,1.1,0.1,Iris-setosa
16 | 15,5.8,4.0,1.2,0.2,Iris-setosa
17 | 16,5.7,4.4,1.5,0.4,Iris-setosa
18 | 17,5.4,3.9,1.3,0.4,Iris-setosa
19 | 18,5.1,3.5,1.4,0.3,Iris-setosa
20 | 19,5.7,3.8,1.7,0.3,Iris-setosa
21 | 20,5.1,3.8,1.5,0.3,Iris-setosa
22 | 21,5.4,3.4,1.7,0.2,Iris-setosa
23 | 22,5.1,3.7,1.5,0.4,Iris-setosa
24 | 23,4.6,3.6,1.0,0.2,Iris-setosa
25 | 24,5.1,3.3,1.7,0.5,Iris-setosa
26 | 25,4.8,3.4,1.9,0.2,Iris-setosa
27 | 26,5.0,3.0,1.6,0.2,Iris-setosa
28 | 27,5.0,3.4,1.6,0.4,Iris-setosa
29 | 28,5.2,3.5,1.5,0.2,Iris-setosa
30 | 29,5.2,3.4,1.4,0.2,Iris-setosa
31 | 30,4.7,3.2,1.6,0.2,Iris-setosa
32 | 31,4.8,3.1,1.6,0.2,Iris-setosa
33 | 32,5.4,3.4,1.5,0.4,Iris-setosa
34 | 33,5.2,4.1,1.5,0.1,Iris-setosa
35 | 34,5.5,4.2,1.4,0.2,Iris-setosa
36 | 35,4.9,3.1,1.5,0.1,Iris-setosa
37 | 36,5.0,3.2,1.2,0.2,Iris-setosa
38 | 37,5.5,3.5,1.3,0.2,Iris-setosa
39 | 38,4.9,3.1,1.5,0.1,Iris-setosa
40 | 39,4.4,3.0,1.3,0.2,Iris-setosa
41 | 40,5.1,3.4,1.5,0.2,Iris-setosa
42 | 41,5.0,3.5,1.3,0.3,Iris-setosa
43 | 42,4.5,2.3,1.3,0.3,Iris-setosa
44 | 43,4.4,3.2,1.3,0.2,Iris-setosa
45 | 44,5.0,3.5,1.6,0.6,Iris-setosa
46 | 45,5.1,3.8,1.9,0.4,Iris-setosa
47 | 46,4.8,3.0,1.4,0.3,Iris-setosa
48 | 47,5.1,3.8,1.6,0.2,Iris-setosa
49 | 48,4.6,3.2,1.4,0.2,Iris-setosa
50 | 49,5.3,3.7,1.5,0.2,Iris-setosa
51 | 50,5.0,3.3,1.4,0.2,Iris-setosa
52 | 51,7.0,3.2,4.7,1.4,Iris-versicolor
53 | 52,6.4,3.2,4.5,1.5,Iris-versicolor
54 | 53,6.9,3.1,4.9,1.5,Iris-versicolor
55 | 54,5.5,2.3,4.0,1.3,Iris-versicolor
56 | 55,6.5,2.8,4.6,1.5,Iris-versicolor
57 | 56,5.7,2.8,4.5,1.3,Iris-versicolor
58 | 57,6.3,3.3,4.7,1.6,Iris-versicolor
59 | 58,4.9,2.4,3.3,1.0,Iris-versicolor
60 | 59,6.6,2.9,4.6,1.3,Iris-versicolor
61 | 60,5.2,2.7,3.9,1.4,Iris-versicolor
62 | 61,5.0,2.0,3.5,1.0,Iris-versicolor
63 | 62,5.9,3.0,4.2,1.5,Iris-versicolor
64 | 63,6.0,2.2,4.0,1.0,Iris-versicolor
65 | 64,6.1,2.9,4.7,1.4,Iris-versicolor
66 | 65,5.6,2.9,3.6,1.3,Iris-versicolor
67 | 66,6.7,3.1,4.4,1.4,Iris-versicolor
68 | 67,5.6,3.0,4.5,1.5,Iris-versicolor
69 | 68,5.8,2.7,4.1,1.0,Iris-versicolor
70 | 69,6.2,2.2,4.5,1.5,Iris-versicolor
71 | 70,5.6,2.5,3.9,1.1,Iris-versicolor
72 | 71,5.9,3.2,4.8,1.8,Iris-versicolor
73 | 72,6.1,2.8,4.0,1.3,Iris-versicolor
74 | 73,6.3,2.5,4.9,1.5,Iris-versicolor
75 | 74,6.1,2.8,4.7,1.2,Iris-versicolor
76 | 75,6.4,2.9,4.3,1.3,Iris-versicolor
77 | 76,6.6,3.0,4.4,1.4,Iris-versicolor
78 | 77,6.8,2.8,4.8,1.4,Iris-versicolor
79 | 78,6.7,3.0,5.0,1.7,Iris-versicolor
80 | 79,6.0,2.9,4.5,1.5,Iris-versicolor
81 | 80,5.7,2.6,3.5,1.0,Iris-versicolor
82 | 81,5.5,2.4,3.8,1.1,Iris-versicolor
83 | 82,5.5,2.4,3.7,1.0,Iris-versicolor
84 | 83,5.8,2.7,3.9,1.2,Iris-versicolor
85 | 84,6.0,2.7,5.1,1.6,Iris-versicolor
86 | 85,5.4,3.0,4.5,1.5,Iris-versicolor
87 | 86,6.0,3.4,4.5,1.6,Iris-versicolor
88 | 87,6.7,3.1,4.7,1.5,Iris-versicolor
89 | 88,6.3,2.3,4.4,1.3,Iris-versicolor
90 | 89,5.6,3.0,4.1,1.3,Iris-versicolor
91 | 90,5.5,2.5,4.0,1.3,Iris-versicolor
92 | 91,5.5,2.6,4.4,1.2,Iris-versicolor
93 | 92,6.1,3.0,4.6,1.4,Iris-versicolor
94 | 93,5.8,2.6,4.0,1.2,Iris-versicolor
95 | 94,5.0,2.3,3.3,1.0,Iris-versicolor
96 | 95,5.6,2.7,4.2,1.3,Iris-versicolor
97 | 96,5.7,3.0,4.2,1.2,Iris-versicolor
98 | 97,5.7,2.9,4.2,1.3,Iris-versicolor
99 | 98,6.2,2.9,4.3,1.3,Iris-versicolor
100 | 99,5.1,2.5,3.0,1.1,Iris-versicolor
101 | 100,5.7,2.8,4.1,1.3,Iris-versicolor
102 | 101,6.3,3.3,6.0,2.5,Iris-virginica
103 | 102,5.8,2.7,5.1,1.9,Iris-virginica
104 | 103,7.1,3.0,5.9,2.1,Iris-virginica
105 | 104,6.3,2.9,5.6,1.8,Iris-virginica
106 | 105,6.5,3.0,5.8,2.2,Iris-virginica
107 | 106,7.6,3.0,6.6,2.1,Iris-virginica
108 | 107,4.9,2.5,4.5,1.7,Iris-virginica
109 | 108,7.3,2.9,6.3,1.8,Iris-virginica
110 | 109,6.7,2.5,5.8,1.8,Iris-virginica
111 | 110,7.2,3.6,6.1,2.5,Iris-virginica
112 | 111,6.5,3.2,5.1,2.0,Iris-virginica
113 | 112,6.4,2.7,5.3,1.9,Iris-virginica
114 | 113,6.8,3.0,5.5,2.1,Iris-virginica
115 | 114,5.7,2.5,5.0,2.0,Iris-virginica
116 | 115,5.8,2.8,5.1,2.4,Iris-virginica
117 | 116,6.4,3.2,5.3,2.3,Iris-virginica
118 | 117,6.5,3.0,5.5,1.8,Iris-virginica
119 | 118,7.7,3.8,6.7,2.2,Iris-virginica
120 | 119,7.7,2.6,6.9,2.3,Iris-virginica
121 | 120,6.0,2.2,5.0,1.5,Iris-virginica
122 | 121,6.9,3.2,5.7,2.3,Iris-virginica
123 | 122,5.6,2.8,4.9,2.0,Iris-virginica
124 | 123,7.7,2.8,6.7,2.0,Iris-virginica
125 | 124,6.3,2.7,4.9,1.8,Iris-virginica
126 | 125,6.7,3.3,5.7,2.1,Iris-virginica
127 | 126,7.2,3.2,6.0,1.8,Iris-virginica
128 | 127,6.2,2.8,4.8,1.8,Iris-virginica
129 | 128,6.1,3.0,4.9,1.8,Iris-virginica
130 | 129,6.4,2.8,5.6,2.1,Iris-virginica
131 | 130,7.2,3.0,5.8,1.6,Iris-virginica
132 | 131,7.4,2.8,6.1,1.9,Iris-virginica
133 | 132,7.9,3.8,6.4,2.0,Iris-virginica
134 | 133,6.4,2.8,5.6,2.2,Iris-virginica
135 | 134,6.3,2.8,5.1,1.5,Iris-virginica
136 | 135,6.1,2.6,5.6,1.4,Iris-virginica
137 | 136,7.7,3.0,6.1,2.3,Iris-virginica
138 | 137,6.3,3.4,5.6,2.4,Iris-virginica
139 | 138,6.4,3.1,5.5,1.8,Iris-virginica
140 | 139,6.0,3.0,4.8,1.8,Iris-virginica
141 | 140,6.9,3.1,5.4,2.1,Iris-virginica
142 | 141,6.7,3.1,5.6,2.4,Iris-virginica
143 | 142,6.9,3.1,5.1,2.3,Iris-virginica
144 | 143,5.8,2.7,5.1,1.9,Iris-virginica
145 | 144,6.8,3.2,5.9,2.3,Iris-virginica
146 | 145,6.7,3.3,5.7,2.5,Iris-virginica
147 | 146,6.7,3.0,5.2,2.3,Iris-virginica
148 | 147,6.3,2.5,5.0,1.9,Iris-virginica
149 | 148,6.5,3.0,5.2,2.0,Iris-virginica
150 | 149,6.2,3.4,5.4,2.3,Iris-virginica
151 | 150,5.9,3.0,5.1,1.8,Iris-virginica
152 |
--------------------------------------------------------------------------------
/mygraph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/mygraph.png
--------------------------------------------------------------------------------
/sales_data_of_bathingsoap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/milaan9/11_Python_Matplotlib_Module/4896a9c35d69fbc8528acaa793387e82562118c6/sales_data_of_bathingsoap.png
--------------------------------------------------------------------------------