![]() ![]() ![]() The above code means that we are setting the color of the scatter plot as red. To set the colors of a scatter plot, we need to set the argument color or simply c to the pyplot.scatter() function.įor example, take a look at the code below: plt.scatter(x, y, color = 'red') Setting colors to the multiple scatter plot By default, pyplot returned orange and blue. Note: Notice that the two plots in the figure above gave two different colors. Line 16: The pyplot.show() function is used, which tells pyplot to display both the scatter plots. If you want to change the default blue color you can set a new color. pyplot.scatter(x,y2) is used to create a scatter plot of x and y2. The scatter function provides several arguments to customize the markers in several ways. Lines 12 to 13: The array y2 is created, which contains the y-coordinates for the second scatter plot. pyplot.scatter(x,y1) is used to create a scatter plot of x and y1. Lines 8 to 9: The array y1 is created, which contains the y-coordinates for the first scatter plot. Line 5: The array x is created, containing the x-coordinates common to both plots. Line 2: The numpy module is imported, which will be used to create arrays. For example: import matplotlib.pyplot as plt from matplotlib import colors as mcolors for color, group in df.groupby(Color): plt.scatter(groupA, groupB, ccolor, alpha0.8, labelcolor) plt.legend() plt. Line 1: In matplotlib, the pyplot module is imported, which will be used to create plots. A simple way is to group your data by color, then plot all of the data on one plot. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |