- 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 remove grid lines from an image in Python Matplotlib?
To remove grid lines from an image, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Load an image from a file.
- Convert the image from one color space to another.
- To remove grid lines, use ax.grid(False).
- Display the data as an image, i.e., on a 2D regular raster.
- To display the figure, use show() method.
Example
from matplotlib import pyplot as plt import cv2 plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True img = cv2.imread('bird.jpg') img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) plt.grid(False) plt.imshow(img) plt.show()
Output
- Related Articles
- How to draw grid lines behind Matplotlib bar graph?
- How to remove lines in a Matplotlib plot?
- Removing Horizontal Lines in image (OpenCV, Python, Matplotlib)
- How to change the color and add grid lines to a Python Matplotlib surface plot?
- How to remove empty string/lines from PowerShell?
- How to remove end lines from a boxplot in R?
- Matplotlib – Plot over an image background in Python
- How to make custom grid lines in Seaborn heatmap?
- How to place X-axis grid over a spectrogram in Python Matplotlib?
- CSS Grid Lines
- How to remove an object from a list in Python?
- How to remove an element from a list in Python?
- How to hide lines in Matplotlib?
- How to plot an animated image matrix in matplotlib?
- How to Remove Empty Lines from a File on ubuntu

Advertisements