Matplotlib is a plotting library for creating static, animated, and interactive visualizations in Python. Matplotlib can be used in Python scripts, the Python and IPython shell, web application servers, and various graphical user interface toolkits like Tkinter, awxPython, etc.
In-order to create a scatter plot with several colors in matplotlib, we can use the various methods:
Method #1: Using the parameter marker color i.e. c
The possible values for marker color are:
- A single color format string.
- A 2-D array in which the rows are RGB or RGBA.
Using the c parameter to depict scatter plot with different colors.
Method #2: Using the colormap
Colormap instances are used to convert data values (floats) from the interval [0, 1] to the RGBA color.
Using the colormap to depict scatter plot with RGB colors.
Here, we manually assign the colormap using color codes.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course