- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 plot and work with NaN values in Matplotlib?
To plot and work with NaN values in matplotlib, we can take the following steps −
Create data using numpy with some NaN values.
Use imshow() method to display data as an image, i.e., on a 2D regular raster, with a colormap and data (from step 1).
To display the figure, use show() method.
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True data = np.array([[1., 1.2, 0.89, np.NAN], [1.2, np.NAN, 1.89, 2.09], [.78, .67, np.NAN, 1.78], [np.NAN, 1.56, 1.89, 2.78]] ) plt.imshow(data, cmap="gist_rainbow_r") plt.show()
- How to plot masked and NaN values in Matplotlib?
- How can I plot NaN values as a special color with imshow in Matplotlib?
- How to deal with NaN values while plotting a boxplot using Python Matplotlib?
- Writing numerical values on the plot with Matplotlib
- Python - How to fill NAN values with mean in Pandas?
- How to plot with xgboost.XGBCClassifier.feature_importances_ model? (Matplotlib)
- How to plot with different scales in Matplotlib?
- Matplotlib – How to set xticks and yticks with imshow plot?
- How to plot 2D math vectors with Matplotlib?
- How to create a Swarm Plot with Matplotlib?
- How to plot a Pandas Dataframe with Matplotlib?
- How to plot a smooth line with matplotlib?
- Replace NaN with zero and fill positive infinity values in Python
- Replace NaN with zero and fill negative infinity values in Python
- Gaussian filtering an image with NaN in Python Matplotlib