|
28 | 28 | "\n", |
29 | 29 | "`matplotlib` is a huge module and we will only introduce you to a few plotting tools today.\n", |
30 | 30 | "\n", |
31 | | - "In order to make plots work in Jupyter we need to use a 'magic' command: `%matplotlib inline`\n", |
| 31 | + "In order to make Jupyter show plots just saved with command `plt.savefig()` we need to use a 'magic' command: `%matplotlib inline`\n", |
32 | 32 | "\n", |
33 | 33 | "Most of the functions we will need are in the `matplotlib.pyplot` submodule - so we will only import that today.\n", |
34 | 34 | "\n", |
35 | | - "<div style=\"background-color:#cdefff; border-radius: 5px; padding: 10pt\"><strong>Task:</strong> In the cell below, add a line to import the <code style=\"background-color:#cdefff\">matplotlib.pyplot</code> submodule. It is convential to give this the alias <code style=\"background-color:#cdefff\">mpl</code>. In the same cell import the `pandas` module.</div>\n", |
| 35 | + "<div style=\"background-color:#cdefff; border-radius: 5px; padding: 10pt\"><strong>Task:</strong> In the cell below, add a line to import the <code style=\"background-color:#cdefff\">matplotlib.pyplot</code> submodule. It is convential to give this the alias <code style=\"background-color:#cdefff\">plt</code>. In the same cell import the `pandas` module.</div>\n", |
36 | 36 | "\n", |
37 | 37 | "<br>\n", |
38 | 38 | "<div style=\"background-color:#cdefff; border-radius: 5px; padding: 10pt\"><strong>Task:</strong> Find the matplotlib Documentation on-line. Can you easily navigate the documentation to find useful functions?</div>" |
|
142 | 142 | "import seaborn as sns\n", |
143 | 143 | "\n", |
144 | 144 | "# Create a plot of sepal_length vs sepal_width where colour (hue) is controlled by the species\n", |
145 | | - "# height controls the figure height in inches\n", |
146 | | - "# truncate prevents the regression extending beyond the data\n", |
| 145 | + "#\n", |
| 146 | + "# 'height' controls the figure height in inches\n", |
| 147 | + "# 'truncate' prevents the regression extending beyond the data\n", |
147 | 148 | "sns.lmplot(x='sepal_length',y='sepal_width',data=iris,hue='species',height=5,truncate=True)\n", |
148 | 149 | "\n", |
149 | 150 | "# Save figure\n", |
|
154 | 155 | "cell_type": "markdown", |
155 | 156 | "metadata": {}, |
156 | 157 | "source": [ |
157 | | - "### Faceted Plotting with `seaborn`\n", |
| 158 | + "### Faceted plotting with `seaborn`\n", |
158 | 159 | "\n", |
159 | | - "Isn't that a lot simpler!\n", |
| 160 | + "Isn't that a lot simpler?!\n", |
160 | 161 | "\n", |
161 | 162 | "`seaborn` is doing all the hard work for you - it creates the figure, the scatter plots, the legend and it does the regression and plots the model with error bounds too.\n", |
162 | 163 | "\n", |
|
279 | 280 | "name": "python", |
280 | 281 | "nbconvert_exporter": "python", |
281 | 282 | "pygments_lexer": "ipython3", |
282 | | - "version": "3.7.3" |
| 283 | + "version": "3.7.1" |
283 | 284 | } |
284 | 285 | }, |
285 | 286 | "nbformat": 4, |
|
0 commit comments