

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 convert data values into color information for Matplotlib?
To convert data values into color information for Matplotlib, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Get a colormap instance, defaulting to rc values if *name* is None.
- Create random values that could be converted into color information.
- Create random data points, x and y.
- Use scatter() method to plot x and y.
- To display the figure, use show() method.
Example
import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True plasma = plt.get_cmap('GnBu_r') values = np.random.rand(100) x = np.random.rand(len(values)) y = np.random.rand(len(values)) sc = plt.scatter(x, y, c=[plasma(val) for val in values]) plt.show()
Output
- Related Questions & Answers
- How to vary the line color with data index for line graph in matplotlib?
- How to convert a matrix into a color matrix in R?
- How can I convert numbers to a color scale in Matplotlib?
- How to convert JSON data into a Python tuple?
- How to convert JSON data into a Python object?
- How to convert values greater than a threshold into 1 in R data frame column?
- How to pass RGB color values to Python's Matplotlib eventplot?
- How to interpolate data values into strings in Python?
- How to get boxplot data for Matplotlib boxplots?
- How to convert a vector into data frame in R?
- How to convert primitive data into wrapper class using Java?
- How to plot data into imshow() with custom colormap in Matplotlib?
- How to convert a data frame into two column data frame with values and column name as variable in R?
- How to convert negative values in an R data frame to positive values?
- Getting information for bins in Matplotlib histogram function
Advertisements