Skip to content

Commit 14f659b

Browse files
authored
Merge pull request #24 from lucasd-7905/master
Matplotlib Docs (Incomplete)
2 parents bd44a0b + 0feecda commit 14f659b

3 files changed

Lines changed: 362 additions & 0 deletions

File tree

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "4c983a83-8172-4b50-b428-b65eb006acc2",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"import numpy as np\n",
11+
"import pandas as pd\n",
12+
"import matplotlib.pyplot as plt"
13+
]
14+
},
15+
{
16+
"cell_type": "markdown",
17+
"id": "9b6f0144-2402-43ec-927a-33517502a59d",
18+
"metadata": {},
19+
"source": [
20+
"## Searching the Docs - Matplotlib!\n",
21+
"#### Introduction:"
22+
]
23+
},
24+
{
25+
"cell_type": "markdown",
26+
"id": "75ab876e-424b-4cd3-929e-f6d40c13cc67",
27+
"metadata": {},
28+
"source": [
29+
"### Task 1: Finding argument options from the documentation page\n",
30+
"\n",
31+
"Here is some code to create a linear plot. The datapoints have been defined as a circle.\n",
32+
"1. Can you change the markers to crosses?\n",
33+
" > **Hint:** Where has the datapoint style been defined in the code?\n",
34+
"2. Now can you change them to be squares?\n",
35+
" > **Hint:** Take a look at the `matplotlib.markers` documentation page [here](matplotlib.org/stable/api/markers_api.html#module-matplotlib.markers).\n",
36+
"3. Can you change the linestyle to be a dotted line?\n",
37+
" > **Hint:** Find the linestyle menu on `matplotlib.pyplot.plot` documentation page [here](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.plot.html).\n",
38+
"4. Now can you increase the data point size?\n",
39+
" > **Hint:** What did you do in task 3?"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": null,
45+
"id": "ab5c3579-d62e-4751-b182-682fc4c2531f",
46+
"metadata": {},
47+
"outputs": [],
48+
"source": [
49+
"T = np.array([700, 750, 800, 850, 900])\n",
50+
"k = np.array([1.5e-5, 4.9e-4, 5.9e-3, 4.7e-2, 5.5e-1])\n",
51+
"\n",
52+
"plt.plot(1000/T, np.log(k), marker='o', linestyle='-')\n",
53+
"plt.show()"
54+
]
55+
},
56+
{
57+
"cell_type": "markdown",
58+
"id": "95dfea33-1642-4653-8a80-ba4dc8ff3d9e",
59+
"metadata": {},
60+
"source": [
61+
"### Task 2: Exploring Pyplot Functions"
62+
]
63+
},
64+
{
65+
"cell_type": "markdown",
66+
"id": "321ad4e0-b412-49af-b941-fdadf740617c",
67+
"metadata": {},
68+
"source": [
69+
"1. Explore the [matplotlib.pyplot](https://matplotlib.org/stable/api/pyplot_summary.html#module-matplotlib.pyplot) documentation page to find the function to change the y axis scale to a log scale. Once found, ammend the code below accordingly.\n",
70+
"2. Explore the [matplotlib.pyplot](https://matplotlib.org/stable/api/pyplot_summary.html#module-matplotlib.pyplot) documentation page to format the x and y axis major and minor ticks. Update the code accordingly. "
71+
]
72+
},
73+
{
74+
"cell_type": "code",
75+
"execution_count": null,
76+
"id": "951f91a1-0e80-43ec-aaa0-97ac7976432d",
77+
"metadata": {},
78+
"outputs": [],
79+
"source": [
80+
"data = np.genfromtxt(\"Venus data.csv\", skip_header=1, delimiter=',', dtype=float, usecols=(1, 2, 3))\n",
81+
"\n",
82+
"plt.plot(data[:, 0], data[:, 1], color='b', label=\"SO\")\n",
83+
"plt.plot(data[:, 0], data[:, 2], color='r', label=r\"SO$_2$\")\n",
84+
"plt.xlabel('Altitude (km)', fontsize=14)\n",
85+
"plt.ylabel('Mixing Ratio (ppm)', fontsize=14)\n",
86+
"plt.xlim(0, 180)\n",
87+
"plt.ylim(0, 1e-5)\n",
88+
"plt.minorticks_on()\n",
89+
"plt.legend(frameon=False, fontsize=14)\n",
90+
"plt.show()"
91+
]
92+
},
93+
{
94+
"cell_type": "markdown",
95+
"id": "3ffabcd1-fc1e-4394-9524-3eb4271e6a34",
96+
"metadata": {},
97+
"source": [
98+
"### Task 3: Different Plot Types\n",
99+
"\n",
100+
"1. Create a boxplot from data and format it appropriately\n",
101+
"2. Create a violinplot (displaying mean values) and format it appropriately"
102+
]
103+
},
104+
{
105+
"cell_type": "code",
106+
"execution_count": null,
107+
"id": "510c0e66-df4f-42ea-91dd-c35a8710e6bc",
108+
"metadata": {},
109+
"outputs": [],
110+
"source": [
111+
"data = np.genfromtxt(\"Vit C in Orange Juice.csv\", skip_header=1, delimiter=',', dtype=float)\n",
112+
"\n",
113+
"plt.boxplot(data)\n",
114+
"plt.show()\n",
115+
"\n",
116+
"plt.violinplot(data, showmeans=True)\n",
117+
"plt.show()"
118+
]
119+
},
120+
{
121+
"cell_type": "markdown",
122+
"id": "b1bbdbd4-78ce-4010-a41d-0ac3dabe7d39",
123+
"metadata": {},
124+
"source": [
125+
"# TODO:\n",
126+
"\n",
127+
"- Searching\n",
128+
"- Understanding scary examples\n",
129+
"- A non-coding activity (MCQ/Drag and drop style)"
130+
]
131+
},
132+
{
133+
"cell_type": "code",
134+
"execution_count": null,
135+
"id": "b204a3c2-ed09-4725-b712-acb6ffcd3645",
136+
"metadata": {},
137+
"outputs": [],
138+
"source": []
139+
}
140+
],
141+
"metadata": {
142+
"kernelspec": {
143+
"display_name": "Python 3 (ipykernel)",
144+
"language": "python",
145+
"name": "python3"
146+
},
147+
"language_info": {
148+
"codemirror_mode": {
149+
"name": "ipython",
150+
"version": 3
151+
},
152+
"file_extension": ".py",
153+
"mimetype": "text/x-python",
154+
"name": "python",
155+
"nbconvert_exporter": "python",
156+
"pygments_lexer": "ipython3",
157+
"version": "3.12.8"
158+
}
159+
},
160+
"nbformat": 4,
161+
"nbformat_minor": 5
162+
}

notebooks/PyInChem/Venus data.csv

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
,altitude,so,so2
2+
1,-0.704689723,6.10E-16,7.35E-06
3+
2,-0.665537672,6.14E-16,7.35E-06
4+
3,-0.560130865,6.38E-16,7.35E-06
5+
4,-0.338212662,7.16E-16,7.35E-06
6+
5,0.04588663,8.12E-16,7.35E-06
7+
6,0.636510833,9.03E-16,7.35E-06
8+
7,1.475348372,9.73E-16,7.35E-06
9+
8,2.600597941,1.02E-15,7.36E-06
10+
9,4.04613478,1.06E-15,7.39E-06
11+
10,5.840365711,1.07E-15,7.44E-06
12+
11,8.004692432,1.27E-15,7.56E-06
13+
12,10.55303372,5.92E-15,7.72E-06
14+
13,13.49135509,2.57E-14,7.91E-06
15+
14,16.81617891,6.80E-14,8.11E-06
16+
15,20.50942658,1.33E-13,8.27E-06
17+
16,24.44175194,2.84E-13,8.37E-06
18+
17,28.33343924,6.29E-13,8.43E-06
19+
18,32.01034726,1.10E-14,8.47E-06
20+
19,35.47595331,1.08E-15,8.47E-06
21+
20,38.71806531,3.80E-16,8.30E-06
22+
21,41.71853186,1.26E-16,7.90E-06
23+
22,44.50716306,1.23E-15,7.36E-06
24+
23,47.13362277,1.08E-14,6.92E-06
25+
24,49.60762433,7.45E-14,6.73E-06
26+
25,51.92295942,3.59E-13,6.65E-06
27+
26,54.07841631,1.55E-12,6.57E-06
28+
27,56.0802577,6.21E-12,6.45E-06
29+
28,57.93635846,1.46E-11,6.20E-06
30+
29,59.66297308,1.19E-11,5.58E-06
31+
30,61.28797567,2.49E-12,4.49E-06
32+
31,62.84736579,6.18E-12,3.25E-06
33+
32,64.41679145,1.61E-10,2.20E-06
34+
33,66.05791283,6.82E-10,1.38E-06
35+
34,67.75125984,1.32E-09,7.87E-07
36+
35,69.45006449,1.55E-09,4.30E-07
37+
36,71.12910436,1.55E-09,2.44E-07
38+
37,72.78328276,1.47E-09,1.60E-07
39+
38,74.42006023,1.41E-09,1.26E-07
40+
39,76.06583954,1.52E-09,1.11E-07
41+
40,77.73644499,1.69E-09,1.04E-07
42+
41,79.41103965,1.91E-09,9.87E-08
43+
42,81.05759183,2.12E-09,9.49E-08
44+
43,82.66393287,2.34E-09,9.35E-08
45+
44,84.22272226,2.64E-09,9.46E-08
46+
45,85.72809876,3.08E-09,9.58E-08
47+
46,87.39159687,3.76E-09,9.39E-08
48+
47,89.52876629,4.99E-09,9.01E-08
49+
48,92.09026302,7.54E-09,8.97E-08
50+
49,94.95427289,1.27E-08,8.88E-08
51+
50,98.00461311,1.46E-08,8.49E-08
52+
51,100.3931795,1.49E-08,7.89E-08
53+
52,102.2482482,1.41E-08,7.50E-08
54+
53,104.202286,1.75E-08,6.84E-08
55+
54,106.2514884,2.43E-08,6.02E-08
56+
55,108.367703,3.22E-08,5.17E-08
57+
56,110.5543634,4.18E-08,4.19E-08
58+
57,112.844633,5.25E-08,3.08E-08
59+
58,115.1585347,6.07E-08,2.19E-08
60+
59,117.3241908,6.62E-08,1.54E-08
61+
60,119.3478514,6.99E-08,1.07E-08
62+
61,121.2903091,7.22E-08,6.78E-09
63+
62,123.215108,7.30E-08,3.70E-09
64+
63,125.1267531,7.18E-08,1.84E-09
65+
64,126.9761047,6.87E-08,9.27E-10
66+
65,128.9080548,6.42E-08,4.77E-10
67+
66,130.9197488,5.87E-08,2.36E-10
68+
67,132.9497676,5.30E-08,1.16E-10
69+
68,135.0520522,4.72E-08,5.81E-11
70+
69,137.2246967,4.11E-08,2.41E-11
71+
70,139.5137683,3.48E-08,8.62E-12
72+
71,141.972967,2.87E-08,3.08E-12
73+
72,144.7091226,2.27E-08,1.22E-12
74+
73,147.8488383,1.70E-08,5.20E-13
75+
74,151.5060422,1.20E-08,2.54E-13
76+
75,155.7536542,7.86E-09,1.44E-13
77+
76,160.6153844,4.82E-09,8.65E-14
78+
77,166.0589755,2.81E-09,5.09E-14
79+
78,172.0472616,1.62E-09,2.61E-14
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
Freshly squeezed orange juice - Unpasteurised (mg/100 mL),Premium (Industry pasteurised) juice (mg/100 mL),Budget (UHT) juice (mg/ 100 mL),Organic Juice (mg/ 100mL)
2+
82.2016,62.0464,32.8016,63.232
3+
98.0096,62.244,36.556,56.316
4+
95.836,65.8008,31.8136,59.0824
5+
101.0724,64.22,41.5948,60.8608
6+
82.992,59.0824,34.7776,63.6272
7+
83.98,63.726,33.4932,59.8728
8+
77.064,64.3188,43.6696,76.9652
9+
101.27,64.714,32.604,65.9984
10+
82.004,60.0704,31.2208,64.0224
11+
97.6144,81.8064,36.556,73.112
12+
76.6688,67.5792,28.0592,56.316
13+
91.1924,54.5376,27.664,48.6096
14+
94.9468,63.4296,33.592,66.3936
15+
70.5432,51.376,51.5736,21.5384
16+
72.124,53.846,22.724,53.352
17+
87.1416,55.5256,27.664,50.5856
18+
99.788,64.22,35.568,65.6032
19+
91.884,63.726,34.58,61.256
20+
70.3456,60.8608,32.0112,60.0704
21+
78.8424,68.172,52.7592,44.46
22+
91.6864,55.7232,25.8856,52.7592
23+
87.0428,67.184,33.6908,45.6456
24+
98.8,65.9984,37.4452,61.256
25+
91.4888,56.7112,28.8496,50.388
26+
85.5608,67.184,33.7896,57.1064
27+
82.2016,63.4296,37.7416,63.0344
28+
78.2496,55.1304,17.1912,52.5616
29+
84.3752,61.6512,31.616,45.8432
30+
94.4528,63.8248,35.3704,64.0224
31+
94.848,53.352,17.784,56.6124
32+
91.4888,54.1424,13.4368,54.34
33+
95.836,59.28,29.146,64.22
34+
67.5792,57.5016,21.736,51.1784
35+
71.4324,45.2504,6.916,42.5828
36+
72.9144,57.304,30.5292,50.388
37+
99.1952,58.8848,28.2568,61.256
38+
113.62,51.376,8.892,47.424
39+
90.1056,52.364,21.5384,51.7712
40+
101.9616,64.8128,34.3824,62.4416
41+
82.2016,61.3548,34.1848,43.5708
42+
120.2396,74.4952,31.2208,81.3124
43+
70.3456,60.0704,35.3704,61.6512
44+
86.5488,61.1572,34.4812,53.0556
45+
85.7584,65.8996,33.8884,65.3068
46+
88.7224,60.268,25.2928,50.9808
47+
79.04,63.4296,33.7896,66.196
48+
79.2376,57.1064,38.1368,48.6096
49+
90.5008,64.0224,32.0112,64.6152
50+
86.944,60.268,30.628,54.34
51+
96.824,66.196,33.592,63.3308
52+
0,64.22,29.64,63.232
53+
70.3456,62.6392,34.58,65.208
54+
95.836,60.268,33.592,59.28
55+
71.63,57.4028,14.326,50.5856
56+
104.728,103.9376,28.652,64.22
57+
84.5728,59.0824,21.736,52.9568
58+
98.0096,67.184,39.52,61.256
59+
84.968,63.8248,33.3944,72.124
60+
82.004,52.7592,41.496,73.112
61+
96.824,41.496,23.712,58.292
62+
83.7824,62.244,33.3944,64.6152
63+
96.824,62.4416,30.8256,57.6992
64+
95.4408,63.6272,31.0232,58.9836
65+
94.0576,64.8128,36.4572,64.0224
66+
86.3512,62.0464,33.1968,64.0224
67+
83.98,64.4176,33.4932,60.268
68+
77.558,73.7048,42.6816,76.076
69+
98.8,65.208,34.086,65.208
70+
84.968,64.0224,32.0112,64.0224
71+
94.0576,79.4352,36.7536,65.702
72+
77.8544,66.3936,24.5024,56.9088
73+
89.1176,55.1304,22.9216,46.0408
74+
95.9348,63.6272,30.8256,66.196
75+
70.3456,51.7712,51.5736,20.9456
76+
75.088,53.9448,23.1192,53.352
77+
86.7464,55.822,28.158,51.376
78+
98.8,65.208,34.1848,62.244
79+
90.896,62.6392,35.4692,61.4536
80+
81.2136,64.4176,27.2688,64.4176
81+
80.4232,68.3696,47.0288,44.5588
82+
92.6744,57.304,25.2928,52.7592
83+
87.1416,64.22,33.9872,45.6456
84+
98.6024,66.196,37.544,62.244
85+
92.6744,57.304,30.628,51.1784
86+
88.7224,67.3816,33.9872,54.5376
87+
80.6208,61.256,41.496,57.5016
88+
82.3992,52.9568,17.784,56.316
89+
83.3872,55.328,32.604,45.448
90+
95.0456,64.8128,34.1848,0
91+
96.824,52.5616,15.808,52.7592
92+
92.872,53.1544,13.4368,54.5376
93+
90.402,51.376,29.64,60.268
94+
67.7768,58.0944,20.3528,52.364
95+
69.16,50.4868,7.904,42.3852
96+
72.7168,57.304,30.628,50.388
97+
99.5904,61.256,27.4664,61.0584
98+
123.5,59.28,11.856,46.436
99+
89.8092,52.2652,19.76,52.1664
100+
98.8,63.0344,36.1608,60.8608
101+
82.8932,60.6632,35.074,45.7444
102+
119.7456,78.9412,31.2208,79.534
103+
70.7408,59.0824,33.592,62.4416
104+
82.6956,60.762,33.2956,53.352
105+
85.6596,65.8996,33.6908,65.5044
106+
90.896,58.292,23.9096,48.8072
107+
84.2764,63.726,34.6788,64.22
108+
79.6328,56.9088,35.1728,46.436
109+
92.0816,64.4176,31.122,65.8008
110+
86.944,61.256,31.8136,53.7472
111+
91.884,64.22,33.098,63.0344
112+
79.6328,63.232,28.4544,57.6992
113+
72.9144,61.256,34.9752,66.7888
114+
94.7492,61.256,32.604,57.304
115+
72.618,58.1932,12.844,0
116+
95.0456,101.764,19.76,65.208
117+
84.5728,60.0704,20.3528,52.7592
118+
97.6144,65.208,37.544,59.0824
119+
84.968,64.22,36.7536,69.16
120+
87.932,61.256,37.544,68.172
121+
96.824,47.424,27.664,59.28

0 commit comments

Comments
 (0)