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()