- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to color a Matplotlib scatterplot using a continuous value?
To color a matplotlib scatterplot using continuous value, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Create x, y and z random data points using numpy.
Create a figure and a set of subplots.
Create a scatter plot.
Draw a colorbar in an existing axes, with scatter points scalar mappable instance.
To display the figure, use show() method.
import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x, y, z = np.random.rand(3, 50) f, ax = plt.subplots() points = ax.scatter(x, y, c=z, s=50, cmap="plasma") f.colorbar(points) plt.show()
- Related Articles
- How to color scatterplot points based on a threshold using ggplot2 in R?
- How to redefine a color for a specific value in a Matplotlib colormap?
- How to change the color of points in a scatterplot using ggplot2 in R?
- How to plot a 3D continuous line in Matplotlib?
- How to change the color of points for ggplot2 scatterplot using color brewer in R?
- How to change the face color of a plot using Matplotlib?
- How to change the color of a line using radiobuttons in Matplotlib?
- How to move the legend to outside of a Seaborn scatterplot in Matplotlib?
- How to create a scatterplot using ggplot2 with different shape and color of points based on a variable in R?
- How to create scatterplot for categories with grey color palette using ggplot2 in R?
- How to make a basic Scatterplot using Python-Plotly?
- How to plot a gradient color line in matplotlib?
- How to fill color below a curve in Matplotlib?
- How to modify a 2d Scatterplot to display color based on a third array in a CSV file?
- Set Max value for color bar on Seaborn heatmap using Matplotlib