- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
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 save the plot to a numpy array in RGB format?
To save the plot to a numpy array in RGB format, we can take the following steps −
Create r, g and b random array using numpy.
Zip r, g and b (grom step 1) to make an rgb tuple list.
Convert rgb into a numpy array to plot it.
Plot the numpy array that is in rgb format.
Save the figure at the current location.
To display the figure, use the show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True r = np.random.rand(100) g = np.random.rand(100) b = np.random.rand(100) rgb = zip(r, g, b) arr = np.array([item for item in rgb]) plt.plot(arr) plt.savefig("myplot.png") plt.show()
Output
- Related Articles
- How to create a plot using rgb colors in R?
- How to save an array as a grayscale image with Matplotlib/Numpy?
- How to save a histogram plot in Python?
- How to save a plot in pdf in R?
- How to save a plot in Seaborn with Python (Matplotlib)?
- How to save a plot as SVG created with ggplot2 in R?
- How to save a Librosa spectrogram plot as a specific sized image?
- How to save JSON array to MySQL database?
- How can Keras be used to save model using hdf5 format in Python?
- Creating a 3D plot in Matplotlib from a 3D numpy array
- How to add a vector to a given Numpy array?
- How to create a series from a NumPy array?
- How to use rgb color codes in tkinter?
- How to create a numpy array within a given range?
- How to convert a PyTorch tensor with gradient to a numpy array?

Advertisements