From ae6407e382f1ea8a96bacaecfea816963665fb54 Mon Sep 17 00:00:00 2001 From: Andy Bryant Date: Tue, 19 Jan 2021 09:45:53 -0500 Subject: [PATCH] added matplotlib to requirements --- .../part_1/binder/requirements.txt | 1 + intro_data_science/part_1/ds_part_1.ipynb | 21 +++++++++++++ .../part_1/ds_part_1_complete.ipynb | 30 +++++++++++++++++-- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/intro_data_science/part_1/binder/requirements.txt b/intro_data_science/part_1/binder/requirements.txt index 3fd8886..2cd8fdb 100644 --- a/intro_data_science/part_1/binder/requirements.txt +++ b/intro_data_science/part_1/binder/requirements.txt @@ -1 +1,2 @@ pandas==1.2.0 +matplotlib==3.3.3 \ No newline at end of file diff --git a/intro_data_science/part_1/ds_part_1.ipynb b/intro_data_science/part_1/ds_part_1.ipynb index 234f8ba..154160b 100644 --- a/intro_data_science/part_1/ds_part_1.ipynb +++ b/intro_data_science/part_1/ds_part_1.ipynb @@ -2248,6 +2248,27 @@ "source": [ "https://jakevdp.github.io/PythonDataScienceHandbook/02.05-computation-on-arrays-broadcasting.html" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Plot sin and cos on the same graph, using matplotlib\n", + "# Compute the x and y coordinates for points on sine and cosine curves \n", + "\n", + "# Set up a subplot grid that has height 2 and width 1, \n", + "# and set the first such subplot as active. \n", + "\n", + "# Make the first plot \n", + " \n", + "# Set the second subplot as active, and make the second plot. \n", + "\n", + "# Ensure tight layout\n", + " \n", + "# Show the figure. " + ] } ], "metadata": { diff --git a/intro_data_science/part_1/ds_part_1_complete.ipynb b/intro_data_science/part_1/ds_part_1_complete.ipynb index f43ffc7..c568ea9 100644 --- a/intro_data_science/part_1/ds_part_1_complete.ipynb +++ b/intro_data_science/part_1/ds_part_1_complete.ipynb @@ -19,7 +19,8 @@ "import numpy as np\n", "from IPython.display import Image\n", "import time\n", - "from sys import getsizeof" + "from sys import getsizeof\n", + "import matplotlib.pyplot" ] }, { @@ -2404,7 +2405,32 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "# Plot sin and cos on the same graph, using matplotlib\n", + "# Compute the x and y coordinates for points on sine and cosine curves \n", + "x = np.arange(0, 5 * np.pi, 0.1) \n", + "y_sin = np.sin(x) \n", + "y_cos = np.cos(x) \n", + " \n", + "# Set up a subplot grid that has height 2 and width 1, \n", + "# and set the first such subplot as active. \n", + "plt.subplot(2, 1, 1)\n", + " \n", + "# Make the first plot \n", + "plt.plot(x, y_sin) \n", + "plt.title('Sine') \n", + " \n", + "# Set the second subplot as active, and make the second plot. \n", + "plt.subplot(2, 1, 2) \n", + "plt.plot(x, y_cos) \n", + "plt.title('Cosine') \n", + "\n", + "# Ensure tight layout\n", + "plt.tight_layout()\n", + " \n", + "# Show the figure. \n", + "plt.show()" + ] } ], "metadata": {