From 72d0f8b58be8f78ca8842b61baa74f596da27a28 Mon Sep 17 00:00:00 2001 From: Gregory Brunner Date: Fri, 31 Mar 2017 21:36:42 -0500 Subject: [PATCH] customizations for class --- notebooks/02.00-Introduction-to-NumPy.ipynb | 8 +++- .../04.00-Introduction-To-Matplotlib.ipynb | 21 +++++---- notebooks/04.01-Simple-Line-Plots.ipynb | 47 ++++++++++++------- notebooks/04.02-Simple-Scatter-Plots.ipynb | 38 ++++++++------- 4 files changed, 72 insertions(+), 42 deletions(-) diff --git a/notebooks/02.00-Introduction-to-NumPy.ipynb b/notebooks/02.00-Introduction-to-NumPy.ipynb index c9ad97f9c..73ba84ab5 100644 --- a/notebooks/02.00-Introduction-to-NumPy.ipynb +++ b/notebooks/02.00-Introduction-to-NumPy.ipynb @@ -121,6 +121,12 @@ "In [4]: np?\n", "```\n", "\n", + "And in PyScripter\n", + "\n", + "```pyscripter\n", + ">> help(np)\n", + "```\n", + "\n", "More detailed documentation, along with tutorials and other resources, can be found at http://www.numpy.org." ] }, @@ -150,7 +156,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.1" + "version": "3.5.3" } }, "nbformat": 4, diff --git a/notebooks/04.00-Introduction-To-Matplotlib.ipynb b/notebooks/04.00-Introduction-To-Matplotlib.ipynb index 7c19c7da5..2b8fe4780 100644 --- a/notebooks/04.00-Introduction-To-Matplotlib.ipynb +++ b/notebooks/04.00-Introduction-To-Matplotlib.ipynb @@ -250,7 +250,8 @@ "\n", "fig = plt.figure()\n", "plt.plot(x, np.sin(x), '-')\n", - "plt.plot(x, np.cos(x), '--');" + "plt.plot(x, np.cos(x), '--');\n", + "plt.show()" ] }, { @@ -272,7 +273,7 @@ }, "outputs": [], "source": [ - "fig.savefig('my_figure.png')" + "fig.savefig('my_figure.png') #Give it a folder path too!" ] }, { @@ -298,7 +299,7 @@ } ], "source": [ - "!ls -lh my_figure.png" + "# !ls -lh my_figure.png" ] }, { @@ -328,8 +329,8 @@ } ], "source": [ - "from IPython.display import Image\n", - "Image('my_figure.png')" + "# from IPython.display import Image\n", + "#Image('my_figure.png')" ] }, { @@ -429,7 +430,9 @@ "\n", "# create the second panel and set current axis\n", "plt.subplot(2, 1, 2)\n", - "plt.plot(x, np.cos(x));" + "plt.plot(x, np.cos(x));\n", + "\n", + "plt.show()" ] }, { @@ -481,7 +484,9 @@ "\n", "# Call plot() method on the appropriate object\n", "ax[0].plot(x, np.sin(x))\n", - "ax[1].plot(x, np.cos(x));" + "ax[1].plot(x, np.cos(x));\n", + "\n", + "plt.show()" ] }, { @@ -519,7 +524,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.1" + "version": "3.5.3" } }, "nbformat": 4, diff --git a/notebooks/04.01-Simple-Line-Plots.ipynb b/notebooks/04.01-Simple-Line-Plots.ipynb index e32b61cc7..0c3f665a1 100644 --- a/notebooks/04.01-Simple-Line-Plots.ipynb +++ b/notebooks/04.01-Simple-Line-Plots.ipynb @@ -43,9 +43,8 @@ }, "outputs": [], "source": [ - "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", - "plt.style.use('seaborn-whitegrid')\n", + "plt.style.use('seaborn-whitegrid') #plt.style.use('classic')\n", "import numpy as np" ] }, @@ -114,7 +113,8 @@ "ax = plt.axes()\n", "\n", "x = np.linspace(0, 10, 1000)\n", - "ax.plot(x, np.sin(x));" + "ax.plot(x, np.sin(x));\n", + "plt.show()" ] }, { @@ -144,7 +144,8 @@ } ], "source": [ - "plt.plot(x, np.sin(x));" + "plt.plot(x, np.sin(x));\n", + "plt.show()" ] }, { @@ -174,7 +175,8 @@ ], "source": [ "plt.plot(x, np.sin(x))\n", - "plt.plot(x, np.cos(x));" + "plt.plot(x, np.cos(x));\n", + "plt.show()" ] }, { @@ -226,7 +228,8 @@ "plt.plot(x, np.sin(x - 2), color='0.75') # Grayscale between 0 and 1\n", "plt.plot(x, np.sin(x - 3), color='#FFDD44') # Hex code (RRGGBB from 00 to FF)\n", "plt.plot(x, np.sin(x - 4), color=(1.0,0.2,0.3)) # RGB tuple, values 0 to 1\n", - "plt.plot(x, np.sin(x - 5), color='chartreuse'); # all HTML color names supported" + "plt.plot(x, np.sin(x - 5), color='chartreuse'); # all HTML color names supported\n", + "plt.show()" ] }, { @@ -266,7 +269,8 @@ "plt.plot(x, x + 4, linestyle='-') # solid\n", "plt.plot(x, x + 5, linestyle='--') # dashed\n", "plt.plot(x, x + 6, linestyle='-.') # dashdot\n", - "plt.plot(x, x + 7, linestyle=':'); # dotted" + "plt.plot(x, x + 7, linestyle=':'); # dotted\n", + "plt.show()" ] }, { @@ -298,7 +302,8 @@ "plt.plot(x, x + 0, '-g') # solid green\n", "plt.plot(x, x + 1, '--c') # dashed cyan\n", "plt.plot(x, x + 2, '-.k') # dashdot black\n", - "plt.plot(x, x + 3, ':r'); # dotted red" + "plt.plot(x, x + 3, ':r'); # dotted red\n", + "plt.show()" ] }, { @@ -342,7 +347,8 @@ "plt.plot(x, np.sin(x))\n", "\n", "plt.xlim(-1, 11)\n", - "plt.ylim(-1.5, 1.5);" + "plt.ylim(-1.5, 1.5);\n", + "plt.show()" ] }, { @@ -374,7 +380,8 @@ "plt.plot(x, np.sin(x))\n", "\n", "plt.xlim(10, 0)\n", - "plt.ylim(1.2, -1.2);" + "plt.ylim(1.2, -1.2);\n", + "plt.show()" ] }, { @@ -405,7 +412,8 @@ ], "source": [ "plt.plot(x, np.sin(x))\n", - "plt.axis([-1, 11, -1.5, 1.5]);" + "plt.axis([-1, 11, -1.5, 1.5]);\n", + "plt.show()" ] }, { @@ -435,7 +443,8 @@ ], "source": [ "plt.plot(x, np.sin(x))\n", - "plt.axis('tight');" + "plt.axis('tight');\n", + "plt.show()" ] }, { @@ -465,7 +474,8 @@ ], "source": [ "plt.plot(x, np.sin(x))\n", - "plt.axis('equal');" + "plt.axis('equal');\n", + "plt.show()" ] }, { @@ -508,7 +518,8 @@ "plt.plot(x, np.sin(x))\n", "plt.title(\"A Sine Curve\")\n", "plt.xlabel(\"x\")\n", - "plt.ylabel(\"sin(x)\");" + "plt.ylabel(\"sin(x)\");\n", + "plt.show()" ] }, { @@ -552,7 +563,8 @@ "plt.plot(x, np.cos(x), ':b', label='cos(x)')\n", "plt.axis('equal')\n", "\n", - "plt.legend();" + "plt.legend();\n", + "plt.show()" ] }, { @@ -605,7 +617,8 @@ "ax.plot(x, np.sin(x))\n", "ax.set(xlim=(0, 10), ylim=(-2, 2),\n", " xlabel='x', ylabel='sin(x)',\n", - " title='A Simple Plot');" + " title='A Simple Plot');\n", + "plt.show()" ] }, { @@ -634,7 +647,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.1" + "version": "3.5.3" } }, "nbformat": 4, diff --git a/notebooks/04.02-Simple-Scatter-Plots.ipynb b/notebooks/04.02-Simple-Scatter-Plots.ipynb index de850cc00..1252dc3a8 100644 --- a/notebooks/04.02-Simple-Scatter-Plots.ipynb +++ b/notebooks/04.02-Simple-Scatter-Plots.ipynb @@ -43,7 +43,6 @@ }, "outputs": [], "source": [ - "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "plt.style.use('seaborn-whitegrid')\n", "import numpy as np" @@ -81,7 +80,8 @@ "x = np.linspace(0, 10, 30)\n", "y = np.sin(x)\n", "\n", - "plt.plot(x, y, 'o', color='black');" + "plt.plot(x, y, 'o', color='black');\n", + "plt.show()" ] }, { @@ -115,7 +115,8 @@ " plt.plot(rng.rand(5), rng.rand(5), marker,\n", " label=\"marker='{0}'\".format(marker))\n", "plt.legend(numpoints=1)\n", - "plt.xlim(0, 1.8);" + "plt.xlim(0, 1.8);\n", + "plt.show()" ] }, { @@ -144,7 +145,8 @@ } ], "source": [ - "plt.plot(x, y, '-ok');" + "plt.plot(x, y, '-ok');\n", + "plt.show()" ] }, { @@ -178,7 +180,8 @@ " markerfacecolor='white',\n", " markeredgecolor='gray',\n", " markeredgewidth=2)\n", - "plt.ylim(-1.2, 1.2);" + "plt.ylim(-1.2, 1.2);\n", + "plt.show()" ] }, { @@ -217,7 +220,8 @@ } ], "source": [ - "plt.scatter(x, y, marker='o');" + "plt.scatter(x, y, marker='o');\n", + "plt.show()" ] }, { @@ -257,7 +261,8 @@ "\n", "plt.scatter(x, y, c=colors, s=sizes, alpha=0.3,\n", " cmap='viridis')\n", - "plt.colorbar(); # show color scale" + "plt.colorbar(); # show color scale\n", + "plt.show()" ] }, { @@ -289,14 +294,15 @@ } ], "source": [ - "from sklearn.datasets import load_iris\n", - "iris = load_iris()\n", - "features = iris.data.T\n", - "\n", - "plt.scatter(features[0], features[1], alpha=0.2,\n", - " s=100*features[3], c=iris.target, cmap='viridis')\n", - "plt.xlabel(iris.feature_names[0])\n", - "plt.ylabel(iris.feature_names[1]);" + "## This won't work. We don't have sci-kit-learn\n", + "#from sklearn.datasets import load_iris\n", + "#iris = load_iris()\n", + "#features = iris.data.T\n", + "#\n", + "#plt.scatter(features[0], features[1], alpha=0.2,\n", + "# s=100*features[3], c=iris.target, cmap='viridis')\n", + "#plt.xlabel(iris.feature_names[0])\n", + "#plt.ylabel(iris.feature_names[1]);" ] }, { @@ -345,7 +351,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.1" + "version": "3.5.3" } }, "nbformat": 4,