We can control the colors used for a scatter plot just as we do for a curve plot. In this recipe, we are going to see how to use the two ways to control the colors of a scatter plot.
The scatter plot function pyplot.scatter()
offers the following two options to control the colors of dots through its color parameter, or its shortcut c
:
Common color for all the dots: If the color parameter is a valid matplotlib color definition, then all the dots will appear in that color.
Individual color for each dot: If the color parameter is a sequence of a valid matplotlib color definition, the ith dot will appear in the ith color. Of course, we have to give the required colors for each dot.