From 1cb4797c70bb20a242fb6a7cb19534295d2cdb80 Mon Sep 17 00:00:00 2001 From: Benjamin Root Date: Mon, 9 Jul 2018 17:21:52 -0400 Subject: [PATCH 1/5] Fix some typos in part3 and a dead link --- AnatomyOfMatplotlib-Part3-HowToSpeakMPL.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AnatomyOfMatplotlib-Part3-HowToSpeakMPL.ipynb b/AnatomyOfMatplotlib-Part3-HowToSpeakMPL.ipynb index 5f7c0e7..d7bbf0e 100644 --- a/AnatomyOfMatplotlib-Part3-HowToSpeakMPL.ipynb +++ b/AnatomyOfMatplotlib-Part3-HowToSpeakMPL.ipynb @@ -43,7 +43,7 @@ "- k: black\n", "- w: white\n", "\n", - "Other colornames that are allowed are the HTML/CSS colornames such as \"burlywood\" and \"chartreuse\". See the [full list](http://www.w3schools.com/html/html_colornames.asp) of the 147 colornames. \n", + "Other colornames that are allowed are the HTML/CSS colornames such as \"burlywood\" and \"chartreuse\". See the [full list](https://www.w3schools.com/Colors/colors_names.asp) of the 140 color names. \n", "\n", "Matplotlib supports the [xkcd color names](https://xkcd.com/color/rgb/) prefxed by `'xkcd:'`.\n", "\n", @@ -112,7 +112,7 @@ "1 | tickright ||5 | caretright ||\">\" | triangle_right||\"4\" | tri_right\n", "2 | tickup ||6 | caretup ||\"^\" | triangle_up ||\"2\" | tri_up\n", "3 | tickdown ||7 | caretdown ||\"v\" | triangle_down ||\"1\" | tri_down\n", - "\"None\" | nothing ||`None` | nothing ||\" \" | nothing ||\"\" | nothing" + "\"None\" | nothing ||`None` | default ||\" \" | nothing ||\"\" | nothing" ] }, { @@ -128,7 +128,7 @@ " \"octagon\", \"square\", \"pentagon\", \"star\", \"vertical bar\", \"horizontal bar\", \"hexagon 1\", \"hexagon 2\",\n", " \"tick left\", \"caret left\", \"triangle left\", \"tri left\", \"tick right\", \"caret right\", \"triangle right\", \"tri right\",\n", " \"tick up\", \"caret up\", \"triangle up\", \"tri up\", \"tick down\", \"caret down\", \"triangle down\", \"tri down\",\n", - " \"Nothing\", \"Nothing\", \"Nothing\", \"Nothing\"]\n", + " \"Nothing\", \"default\", \"Nothing\", \"Nothing\"]\n", "fig, ax = plt.subplots(1, 1, figsize=(7.5, 4))\n", "for x, y, m, d in zip(xs.T.flat, ys.T.flat, markers, descripts):\n", " ax.scatter(x, y, marker=m, s=100)\n", From 7fc0e25fadd477c4138979ffc5b522fcacf4c146 Mon Sep 17 00:00:00 2001 From: Benjamin Root Date: Mon, 9 Jul 2018 17:41:40 -0400 Subject: [PATCH 2/5] Updated link for tick_params and added a bit about categoricals --- AnatomyOfMatplotlib-Part4-Limits_Legends_and_Layouts.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AnatomyOfMatplotlib-Part4-Limits_Legends_and_Layouts.ipynb b/AnatomyOfMatplotlib-Part4-Limits_Legends_and_Layouts.ipynb index 534fc87..c62c8c4 100644 --- a/AnatomyOfMatplotlib-Part4-Limits_Legends_and_Layouts.ipynb +++ b/AnatomyOfMatplotlib-Part4-Limits_Legends_and_Layouts.ipynb @@ -288,7 +288,7 @@ "* A Tick Label is the text that is displayed at that tick.\n", "* A [`Ticker`](http://matplotlib.org/api/ticker_api.html#module-matplotlib.ticker) automatically determines the ticks for an Axis and formats the tick labels.\n", "\n", - "[`tick_params()`](http://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes.tick_params) is often used to help configure your tickers." + "[`tick_params()`](https://matplotlib.org/api/axes_api.html#ticks-and-tick-labels) is often used to help configure your tickers." ] }, { @@ -317,7 +317,7 @@ "source": [ "A commonly-asked question is \"How do I plot non-numerical categories?\"\n", " \n", - "Currently, the easiest way to do this is to \"fake\" the x-values and then change the tick labels to reflect the category.\n", + "Currently, the most reliable way to do this is to \"fake\" the x-values and then change the tick labels to reflect the category. There are some new approaches that work in newer versions of mpl, but the developers are still working out the details of how it should work. In the meantime, \"faking\" the values is the most reliable.\n", "\n", "For example:" ] From 681b78a9e329f2680ae8a812944ad70d6e8b36c7 Mon Sep 17 00:00:00 2001 From: Benjamin Root Date: Mon, 9 Jul 2018 17:56:03 -0400 Subject: [PATCH 3/5] Fix some links in Part 5, and a bare zip() in a solution --- AnatomyOfMatplotlib-Part5-Artists.ipynb | 4 ++-- solutions/5.1-goldstar.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AnatomyOfMatplotlib-Part5-Artists.ipynb b/AnatomyOfMatplotlib-Part5-Artists.ipynb index c52cd26..4da8545 100644 --- a/AnatomyOfMatplotlib-Part5-Artists.ipynb +++ b/AnatomyOfMatplotlib-Part5-Artists.ipynb @@ -161,7 +161,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "To see what properties are set for an artist, use [`getp()`](http://matplotlib.org/api/artist_api.html#matplotlib.artist.getp)" + "To see what properties are set for an artist, use [`getp()`](https://matplotlib.org/api/artist_api.html#functions)" ] }, { @@ -182,7 +182,7 @@ "metadata": {}, "source": [ "# Collections\n", - "In addition to the Figure and Axes containers, there is another special type of container called a [`Collection`](http://matplotlib.org/api/collections_api.html). A Collection usually contains a list of primitives of the same kind that should all be treated similiarly. For example, a [`CircleCollection`](http://matplotlib.org/api/collections_api.html#matplotlib.collections.CircleCollection) would have a list of [`Circle`](http://matplotlib.org/api/artist_api.html#matplotlib.patches.Circle) objects all with the same color, size, and edge width. Individual property values for artists in the collection can also be set (in some cases)." + "In addition to the Figure and Axes containers, there is another special type of container called a [`Collection`](http://matplotlib.org/api/collections_api.html). A Collection usually contains a list of primitives of the same kind that should all be treated similiarly. For example, a [`CircleCollection`](http://matplotlib.org/api/collections_api.html#matplotlib.collections.CircleCollection) would have a list of [`Circle`](https://matplotlib.org/api/_as_gen/matplotlib.patches.Circle.html) objects all with the same color, size, and edge width. Individual property values for artists in the collection can also be set (in some cases)." ] }, { diff --git a/solutions/5.1-goldstar.py b/solutions/5.1-goldstar.py index 21f3272..7a04d3e 100644 --- a/solutions/5.1-goldstar.py +++ b/solutions/5.1-goldstar.py @@ -3,7 +3,7 @@ fig, ax = plt.subplots(1, 1) -offsets = zip([0.2, 0.4, 0.6, 0.8], [0.5] * 4) +offsets = list(zip([0.2, 0.4, 0.6, 0.8], [0.5] * 4)) collection = StarPolygonCollection(5, offsets=offsets, transOffset=ax.transData, From 4538f29bddc02871069a6e36509d574841277bc3 Mon Sep 17 00:00:00 2001 From: Benjamin Root Date: Mon, 9 Jul 2018 23:53:30 -0400 Subject: [PATCH 4/5] Fix a couple of URLs in Part 1. --- AnatomyOfMatplotlib-Part1-Figures_Subplots_and_layouts.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AnatomyOfMatplotlib-Part1-Figures_Subplots_and_layouts.ipynb b/AnatomyOfMatplotlib-Part1-Figures_Subplots_and_layouts.ipynb index efa6b8a..bece646 100644 --- a/AnatomyOfMatplotlib-Part1-Figures_Subplots_and_layouts.ipynb +++ b/AnatomyOfMatplotlib-Part1-Figures_Subplots_and_layouts.ipynb @@ -58,7 +58,7 @@ "[Matplotlib](https://github.com/matplotlib) is hosted by GitHub.\n", "\n", "### Bug Reports and feature requests\n", - "So, you think you found a bug? Or maybe you think some feature is just too difficult to use? Or missing altogether? Submit your bug reports [here](https://github.com/matplotlib/matplotlib/issues) at Matplotlib's issue tracker. We even have a process for submitting and discussing Matplotlib Enhancement Proposals ([MEPs](http://matplotlib.org/devdocs/devel/MEP/index.html))." + "So, you think you found a bug? Or maybe you think some feature is just too difficult to use? Or missing altogether? Submit your bug reports [here](https://github.com/matplotlib/matplotlib/issues) at Matplotlib's issue tracker. We even have a process for submitting and discussing Matplotlib Enhancement Proposals ([MEPs](https://matplotlib.org/devel/MEP/index.html))." ] }, { @@ -200,7 +200,7 @@ "\n", "However, while we're on the topic, you can control the size of the figure through the ``figsize`` argument, which expects a tuple of ``(width, height)`` in inches. \n", "\n", - "A really useful utility function is [`figaspect`](http://matplotlib.org/api/figure_api.html?highlight=figaspect#matplotlib.figure.figaspect)" + "A really useful utility function is [`figaspect`](https://matplotlib.org/api/_as_gen/matplotlib.figure.figaspect.html?highlight=figaspect#matplotlib.figure.figaspect)" ] }, { From 7f673d8ca0c57855e96523606e58c810c839dd98 Mon Sep 17 00:00:00 2001 From: Benjamin Root Date: Tue, 10 Jul 2018 00:24:51 -0400 Subject: [PATCH 5/5] Adopted some of the changes in PR #23 for categoricals --- ...OfMatplotlib-Part4-Limits_Legends_and_Layouts.ipynb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/AnatomyOfMatplotlib-Part4-Limits_Legends_and_Layouts.ipynb b/AnatomyOfMatplotlib-Part4-Limits_Legends_and_Layouts.ipynb index c62c8c4..ec20839 100644 --- a/AnatomyOfMatplotlib-Part4-Limits_Legends_and_Layouts.ipynb +++ b/AnatomyOfMatplotlib-Part4-Limits_Legends_and_Layouts.ipynb @@ -315,9 +315,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "A commonly-asked question is \"How do I plot non-numerical categories?\"\n", - " \n", - "Currently, the most reliable way to do this is to \"fake\" the x-values and then change the tick labels to reflect the category. There are some new approaches that work in newer versions of mpl, but the developers are still working out the details of how it should work. In the meantime, \"faking\" the values is the most reliable.\n", + "A commonly-asked question is \"How do I plot categories?\"\n", + "\n", + "Starting in version 2.0 of mpl, just like any other data.\n", "\n", "For example:" ] @@ -334,9 +334,7 @@ "fruit, value = zip(*data)\n", "\n", "fig, ax = plt.subplots()\n", - "x = np.arange(len(fruit))\n", - "ax.bar(x, value, align='center', color='gray')\n", - "ax.set(xticks=x, xticklabels=fruit)\n", + "ax.bar(fruit, value, align='center', color='gray')\n", "plt.show()" ] },