![]() Y_combined = np. The scatter() function plots one dot for each observation. We use the () method to mark out and label the elements of the graph. With Pyplot, you can use the scatter() function to draw a scatter plot. X_combined_std = np.vstack((X_train_std, X_test_std)) Matplotlib scatter plot legend example We can add a legend to the plot using the matplotlib module. Plt.contourf(xx1, xx2, Z, alpha=0.3, cmap=cmap) Xx1, xx2 = np.meshgrid(np.arange(x1_min, x1_max, resolution), If you simply plot the lines and call ax.legend(), you will get the following: from matplotlib import rcParams, cycler import matplotlib.pyplot as plt import numpy as np Fixing random state for reproducibility np. the error I am getting is ValueError: 'c' argument must be a color, a sequence of colors, or a sequence of numbers, notįrom lors import ListedColormapĭef plot_decision_regions(X, y, classifier, test_idx=None, resolution=0.02):Ĭolors = (‘red’, ‘blue’, ‘lightgreen’, ‘gray’, ‘cyan’)Ĭmap = ListedColormap(colors) I am not sure I think I have a new version of matplotlib v3.4.2, other students are using versions 3.3.2 & 3.3.4. To plot data and draw a colorbar or legend. In Chapter 3 page 89 there are examples creating circles around the plots to identify as test sets. In proplot, you can add colorbars and legends on-the-fly by supplying keyword arguments to various PlotAxes commands. I using the example in the book Python Machine Learning by Sebastian Raschkla.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |