Skip to content

Commit fde6794

Browse files
author
Jahn, Kalle L
committed
removed example integers for legend loc kwarg
1 parent e800212 commit fde6794

1 file changed

Lines changed: 3 additions & 17 deletions

File tree

notebooks/part0_python_intro/06_matplotlib.ipynb

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,7 @@
237237
"metadata": {},
238238
"outputs": [],
239239
"source": [
240-
"fig = plt.figure()\n",
241-
"ax = fig.add_axes(\n",
242-
" [0.1, 0.1, 0.8, 0.8]\n",
243-
") # left, bottom, width, height (range 0 to 1)\n",
240+
"fig = plt.subplots()\n",
244241
"ax.plot(x, x**2, label=\"curve1\")\n",
245242
"ax.plot(x, x**3, label=\"curve2\")\n",
246243
"ax.legend();"
@@ -252,26 +249,15 @@
252249
"source": [
253250
"The advantage with this method is that if curves are added or removed from the figure, the legend is automatically updated accordingly.\n",
254251
"\n",
255-
"The `legend` function takes an optional keyword argument `loc` that can be used to specify where in the figure the legend is to be drawn. The allowed values of `loc` are numerical codes for the various places the legend can be drawn. See http://`matplotlib`.org/users/legend_guide.html#legend-location for details. Some of the most common `loc` values are:\n",
256-
"\n",
257-
"```python\n",
258-
"ax.legend(loc=0) # let `matplotlib` decide the optimal location\n",
259-
"ax.legend(loc=1) # upper right corner\n",
260-
"ax.legend(loc=2) # upper left corner\n",
261-
"ax.legend(loc=3) # lower left corner\n",
262-
"ax.legend(loc=4) # lower right corner\n",
263-
"```\n",
264-
"\n",
265-
"# .. many more options are available\n",
266-
"\n",
267-
"Alternatively, location keywords can also be used.\n",
252+
"The `legend` function takes an optional keyword argument `loc` that can be used to specify where in the figure the legend is to be drawn. The allowed values of `loc` are keywords for the various places the legend can be drawn. See https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.legend.html#matplotlib.axes.Axes.legend for details. Some of the most common `loc` values are:\n",
268253
"\n",
269254
"```python\n",
270255
"ax.legend(loc='best')\n",
271256
"ax.legend(loc='upper right')\n",
272257
"ax.legend(loc='upper left')\n",
273258
"ax.legend(loc='lower left')\n",
274259
"ax.legend(loc='lower right')\n",
260+
"ax.legend(loc='lower center')\n",
275261
"```\n",
276262
"\n",
277263
"## Setting colors, linewidths, linetypes\n",

0 commit comments

Comments
 (0)