How to Color Scatterplot by a variable in Matplotlib? Last Updated : 24 Jan, 2021 Comments Improve Suggest changes Like Article Like Report In this article, we are going to see how to color scatterplot by variable in Matplotlib. Here we will use matplotlib.pyplot.scatter() methods matplotlib library is used to draw a scatter plot. Scatter plots are widely used to represent relations among variables and how change in one affects the other. Syntax: matplotlib.pyplot.scatter(x_axis_data, y_axis_data,s=None, c=None, marker=None, cmap=None, vmin=None, vmax=None, alpha=None, linewidths=None, edgecolors=None) Example 1: Color Scatterplot by variable values. In this example, We are going to see how to color scatterplot with their variable value. Here we will plot a simple scatterplot with x and y data, Then will use c attributes for coloring the point(Scatterplot variable points). Python3 import matplotlib.pyplot as plt x =[5, 7, 8, 7, 2, 17, 2, 9, 4, 11, 12, 9, 6] y =[99, 86, 87, 88, 100, 86, 103, 87, 94, 78, 77, 85, 86] plt.scatter(x, y, c = 'red') # To show the plot plt.show() Output: Example 2: Color Scatterplot point with dependent values. In this example, We will plot a variable depending on another variable. Sometimes we need precisely based visualization so in this case, It can help us to visualize the data that depend on another variable. Here we will use three different values for each point and use colormap with specific data. Python3 import matplotlib.pyplot as plt x =[5, 7, 8, 7, 3, 4, 5, 6, 7] y =[99, 86, 87, 88, 4, 43, 34, 22, 12] z = [1,2,3,4, 5, 6, 7, 8, 9] plt.scatter(x, y, c = z , cmap = "magma") Output: Comment More infoAdvertise with us Next Article How to Color Scatterplot by a variable in Matplotlib? kumar_satyam Follow Improve Article Tags : Python Python-matplotlib Practice Tags : python Similar Reads How To Color a Scatter Plot by a Variable in Altair? Altair is a simple and easy to use statistical visualization library for python. It provides many types of visualizations ranging from simple bar charts to compound visualizations like box plots. Scatter Plot is one of the most useful visualizations in the Altair library for bivariate analysis and f 5 min read How to create a Scatter Plot with several colors in Matplotlib? 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 this article, we w 3 min read How to Connect Scatterplot Points With Line in Matplotlib? Prerequisite: Scatterplot using Seaborn in Python Scatterplot can be used with several semantic groupings which can help to understand well in a graph. They can plot two-dimensional graphics that can be enhanced by mapping up to three additional variables while using the semantics of hue, size, and 2 min read How to Set Plot Background Color in Matplotlib? Prerequisites:Â MatplotlibNumpyFrom the below figure one can infer that a plot consists of X-axis, Y-axis, plot title and the axes. By default, the color of the plot is white. If we have to set the background color of the plot so that our plot looks beautiful, we have to make the axes object, by usin 3 min read How to reverse a Colormap using Matplotlib in Python? Prerequisites: Matplotlib Matplotlib has many built-in Colormaps. Colormaps are nothing but the dictionary which maps the integer data/numbers into colors. Colormaps are used to differentiate or distinguish the data in a particular plot. The reason to use the colormaps is that it is easier for human 6 min read Like