Skip to content

Commit 70e9cb2

Browse files
committed
Add question numbers
1 parent 70ac62b commit 70e9cb2

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

python-data/solutions/ex05_matplotlib.ipynb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"id": "6bc7192f-0962-4168-b6c6-5fd44daa24b2",
5454
"metadata": {},
5555
"source": [
56-
"1. Let's create some sample data to plot. Create an array called `xaxis` with the value `[1,2,3,4,5]` and an array called `yaxis` with the value `[2, 16, 4, 8, 7]`. Plot this data on a single axes. Don't forget to import matplotlib!"
56+
"Q1. Let's create some sample data to plot. Create an array called `xaxis` with the value `[1,2,3,4,5]` and an array called `yaxis` with the value `[2, 16, 4, 8, 7]`. Plot this data on a single axes. Don't forget to import matplotlib!"
5757
]
5858
},
5959
{
@@ -109,7 +109,7 @@
109109
"id": "9cfacc0a-5af7-4912-b79e-0ac0743e20e5",
110110
"metadata": {},
111111
"source": [
112-
"2. Create 6 empty plots in a 2x3 grid."
112+
"Q2. Create 6 empty plots in a 2x3 grid."
113113
]
114114
},
115115
{
@@ -170,7 +170,7 @@
170170
"id": "97d9019c-750c-4a23-b023-2c9ed472f154",
171171
"metadata": {},
172172
"source": [
173-
"3. Some inputs won't work as intended. Create a pandas dataframe as follows: \n",
173+
"Q3. Some inputs won't work as intended. Create a pandas dataframe as follows: \n",
174174
"\n",
175175
"```\n",
176176
"df = pd.DataFrame({\n",
@@ -258,7 +258,7 @@
258258
"id": "8d0a5420-bd47-4771-aebb-125ab192f458",
259259
"metadata": {},
260260
"source": [
261-
"4. We need to extract only the numeric values to plot. Let's extract them as a numpy array and try again. Use `np.asarray(df[['A', 'B']])` to create a numpy array from the numeric data. Try plotting it now."
261+
"Q4. We need to extract only the numeric values to plot. Let's extract them as a numpy array and try again. Use `np.asarray(df[['A', 'B']])` to create a numpy array from the numeric data. Try plotting it now."
262262
]
263263
},
264264
{
@@ -316,7 +316,7 @@
316316
"id": "43bcbb06-d568-4091-a7a3-1e6ab4db0358",
317317
"metadata": {},
318318
"source": [
319-
"5. Let's unpack the example given in the tutorial of using matplotlib with string-indexable objects. Instead of passing numpy arrays directly, we'll pass the names of the variables as strings.\n",
319+
"Q5. Let's unpack the example given in the tutorial of using matplotlib with string-indexable objects. Instead of passing numpy arrays directly, we'll pass the names of the variables as strings.\n",
320320
"\n",
321321
"- Let's start by creating the dictionary. Create a variable called data using the following: \n",
322322
" ```\n",
@@ -398,7 +398,7 @@
398398
"id": "ce3d4439-773f-4a61-8556-9967942f7300",
399399
"metadata": {},
400400
"source": [
401-
"6. So far, we've been creating plots in the object oriented way: explicitly creating figures and axes. The pyplot-style is very subtly different - we just don't need to create the axis or subplots.\n",
401+
"Q6. So far, we've been creating plots in the object oriented way: explicitly creating figures and axes. The pyplot-style is very subtly different - we just don't need to create the axis or subplots.\n",
402402
"- Create x axis data using `np.linspace(min, max, num)`. Create 10 values between 0 and 10.\n",
403403
"- Create y axis data using `np.linspace` to create 10 values between 0 and 100.\n",
404404
"- Plot this data on the implicit axes using `plt.plot()` - don't worry about seeting the figsize and layout."
@@ -464,7 +464,7 @@
464464
"id": "1d18ed69-464a-4f6f-af12-4b43de5fb010",
465465
"metadata": {},
466466
"source": [
467-
"7. Let's use the x and y values from before and create some new y values to practice styling plots.\n",
467+
"Q7. Let's use the x and y values from before and create some new y values to practice styling plots.\n",
468468
"- Create `y2 = np.linspace(0, -100, 10)`.\n",
469469
"- Plot both of these sets of data on the same axes using the [Styling Artists example](https://matplotlib.org/stable/users/explain/quick_start.html#styling-artists).\n",
470470
"- Plot the original y data in purple with the `--` linestyle and the new y data in green with the `:` linestyle.\n",
@@ -525,7 +525,7 @@
525525
"id": "d3bba7b2-208b-4927-a246-b1ff18cadbf9",
526526
"metadata": {},
527527
"source": [
528-
"8. There are lots of different customisation options in matplotlib for colour! You can even have different colours for the markers and outlines in a scatter plot. Use the following to generate some data for a scatter plot:\n",
528+
"Q8. There are lots of different customisation options in matplotlib for colour! You can even have different colours for the markers and outlines in a scatter plot. Use the following to generate some data for a scatter plot:\n",
529529
"```\n",
530530
"data1, data2 = np.random.randn(2,100)\n",
531531
"```\n",
@@ -584,7 +584,7 @@
584584
"id": "e1308dc3-fc3c-4a49-a762-3fdb0a54eff4",
585585
"metadata": {},
586586
"source": [
587-
"9. Generate two more scatter plot datasets as we did above then plot all 4 on one graph. Give each dataset a label and a different marker style - e.g. stars (`*`), plus (`P`) or diamonds (`D`). You can see more options for markers [in the documentation](https://matplotlib.org/stable/gallery/lines_bars_and_markers/marker_reference.html)."
587+
"Q9. Generate two more scatter plot datasets as we did above then plot all 4 on one graph. Give each dataset a label and a different marker style - e.g. stars (`*`), plus (`P`) or diamonds (`D`). You can see more options for markers [in the documentation](https://matplotlib.org/stable/gallery/lines_bars_and_markers/marker_reference.html)."
588588
]
589589
},
590590
{
@@ -652,7 +652,7 @@
652652
"id": "a912305e-861a-428b-8223-9d245004baf7",
653653
"metadata": {},
654654
"source": [
655-
"10. Take the plot we just created in the previous question and give it `xlabel`, `ylabel` and a `title` of your choice. Add some text to the plot saying `some text` at `50, 0`. Add an annotation at top saying `some annotation` with a black arrow pointing to some data using `xy=(40,2)` and `xytext=(3,1.5)`. Also add a legend identifying each data set."
655+
"Q10. Take the plot we just created in the previous question and give it `xlabel`, `ylabel` and a `title` of your choice. Add some text to the plot saying `some text` at `50, 0`. Add an annotation at top saying `some annotation` with a black arrow pointing to some data using `xy=(40,2)` and `xytext=(3,1.5)`. Also add a legend identifying each data set."
656656
]
657657
},
658658
{
@@ -726,7 +726,7 @@
726726
"id": "27c4fc57-9ca3-442b-a62b-469a5f7d73c5",
727727
"metadata": {},
728728
"source": [
729-
"11. Let's practice plotting some log scale data.\n",
729+
"Q11. Let's practice plotting some log scale data.\n",
730730
"- Create the xdata using `xdata = np.arange(5)`.\n",
731731
"- Create the ydata using `ydata = np.array([0.1, 0.5, 1, 5, 10])`.\n",
732732
"- Transform the y data by raising it to the power of 10 using `ydata = 10**ydata`.\n",
@@ -792,7 +792,7 @@
792792
"id": "447fc1f2-81e1-4034-bbcb-b00d57ab88b3",
793793
"metadata": {},
794794
"source": [
795-
"12. To demonstrate the difference between automatic and manual ticks, let's create two subplots. Follow the following steps:\n",
795+
"Q12. To demonstrate the difference between automatic and manual ticks, let's create two subplots. Follow the following steps:\n",
796796
"\n",
797797
"- Create some data using `xdata = np.linspace(0, 99, 100)`, and `ydata = np.sin(xdata / 10)`\n",
798798
"- Create a figure with 2 subplots arranged vertically.\n",
@@ -866,7 +866,7 @@
866866
"id": "ecc8e915-c9ad-44a3-9964-2d047516a3bb",
867867
"metadata": {},
868868
"source": [
869-
"13. Let's see how matplotlib handles plotting dates. We'll create a time series plot using an array of dates and random cumulative data:\n",
869+
"Q13. Let's see how matplotlib handles plotting dates. We'll create a time series plot using an array of dates and random cumulative data:\n",
870870
"- Generate a numpy array of dates starting from `2022-01-01` to `2022-01-10` at intervals of 3 hours using `dates=np.arange(np.datetime64('2022-01-01'), np.datetime64('2022-01-10'), np.timedelta64(3, 'h'))`\n",
871871
"- Creative a cumulative sum of random numbers for the same length of the array of dates using `data=np.cumsum(np.random.randn(len(dates)))`\n",
872872
"- Plot the data with the dates on the x axis and `data` on the y axis.\n",
@@ -929,7 +929,7 @@
929929
"id": "0f022a40-f65d-4649-a63e-bcdbd4cdf4a1",
930930
"metadata": {},
931931
"source": [
932-
"14. Let's have a go at plotting some categorical data. We'll create a bar chart using a list of categories and random values:\n",
932+
"Q14. Let's have a go at plotting some categorical data. We'll create a bar chart using a list of categories and random values:\n",
933933
"- Define a list of four fruit names `['apple', 'banana', 'cherry', 'date']`\n",
934934
"- Generate random data for these categories using `np.random.rand()`\n",
935935
"- Create a bar plot using these categories and their corresponding random values using `ax.bar()`"
@@ -993,7 +993,7 @@
993993
"id": "9d86f4d0-fd73-40b4-aa36-beb40ffbab10",
994994
"metadata": {},
995995
"source": [
996-
"15. Let's create a plot that demonstrates the use of both a secondary y-axis and a secondary x-axis with different scales:\n",
996+
"Q15. Let's create a plot that demonstrates the use of both a secondary y-axis and a secondary x-axis with different scales:\n",
997997
"- Generate a time series `t` ranging from 0 to 2π with 100 points (hint: use `np.linspace` with `np.pi`)\n",
998998
"- Create two datasets: `s` for a sine wave and `l` for a linearly increasing dataset between 0 and the length of `t` (hint: use `np.sin()` and `np.arange()` with `len(t)`)\n",
999999
"- Plot both datasets on the same figure\n",
@@ -1083,7 +1083,7 @@
10831083
"id": "4a4d9f48-0dbc-4b5e-a54a-f440c6c9f46b",
10841084
"metadata": {},
10851085
"source": [
1086-
"16. Let's create a series of suplots to practice visualizing data with colormaps:\n",
1086+
"Q16. Let's create a series of suplots to practice visualizing data with colormaps:\n",
10871087
"- Generate x and y data using `x, y = np.meshgrid(np.linspace(-3, 3, 128), np.linspace(-3, 3, 128))`\n",
10881088
"- Generate Z data using `z = (1 - x/2 + x**5 + y**3) * np.exp(-x**2 - y**2)`\n",
10891089
"- Generate 2 datsets to use for our scatter plot using `np.random.randn(100)` and generate a third dataset to use for the colors using `np.random.rand(100)`\n",
@@ -1189,7 +1189,7 @@
11891189
"id": "4d431ef9-295d-4c21-b9ef-2f4b118b11c6",
11901190
"metadata": {},
11911191
"source": [
1192-
"17. Let's create a figure with multiple subplots using the `suplot_mosiac` method. Each subplot should have its own distinct data and be customized with titles, labels, and a legend. You will also need to manipulate different axes in a single figure and work with multiple figures in a single program:\n",
1192+
"Q17. Let's create a figure with multiple subplots using the `suplot_mosiac` method. Each subplot should have its own distinct data and be customized with titles, labels, and a legend. You will also need to manipulate different axes in a single figure and work with multiple figures in a single program:\n",
11931193
"- Create data for the plots using:\n",
11941194
" ```\n",
11951195
" x = np.linspace(0,2 * np.pi, 100)\n",

0 commit comments

Comments
 (0)