Skip to content

Commit b83dae0

Browse files
committed
add note about matplotlib 1.4 cmap issue in scatter
1 parent 62b4e0f commit b83dae0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

code/ch02/ch02.ipynb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,24 @@
880880
"plt.show()"
881881
]
882882
},
883+
{
884+
"cell_type": "markdown",
885+
"metadata": {},
886+
"source": [
887+
"#### Additional Note (3)\n",
888+
"\n",
889+
"The `plt.scatter` function in the `plot_decision_regions` plot may raise errors if you have matplotlib <= 1.5.0 installed if you use this function to plot more than 4 classes as a reader pointed out: \"[...] if there are four items to be displayed as the RGBA tuple is mis-interpreted as a list of colours\".\n",
890+
"\n",
891+
"```python\n",
892+
"plt.scatter(x=X[y == cl, 0], y=X[y == cl, 1],\n",
893+
" alpha=0.8, c=cmap(idx),\n",
894+
" marker=markers[idx], label=cl)\n",
895+
"```\n",
896+
"\n",
897+
"\n",
898+
"To address this problem in older matplotlib versions, you can replace `c=cmap(idx)` by `c=colors[idx]`."
899+
]
900+
},
883901
{
884902
"cell_type": "markdown",
885903
"metadata": {},

0 commit comments

Comments
 (0)