how to remove grid lines on image in python?
18,152
Solution 1
Apparently something in the background changes the style. I have no experience whatsoever with google colab ti judge whether this can be responsible for the observed difference in displayed image.
In any case it should be possible to manually turn the grid lines off on a per notebook basis.
%matplotlib inline
from matplotlib import pyplot as plt
plt.rcParams["axes.grid"] = False
# rest of code
Solution 2
plt.imshow(myImage)
plt.grid(None) <---- this should remove that white grid
Related videos on Youtube
Author by
Karan Purohit
Updated on October 09, 2022Comments
-
Karan Purohit over 1 year
I am using google colab for my project. I am getting grid lines on images even I am not writing them.
from matplotlib import pyplot as plt %matplotlib inline import cv2 img = cv2.imread('k15.jpg') img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) plt.imshow(img)
for code like above, I am getting grid lines which is not the case when I run the same code in my python shell.
-
python Jocker almost 6 yearsWhen you open it in PIL you need to provide the entirety of the image's path
-
Karan Purohit almost 6 yearsthere is no path as I am using it on google colab. also, same script is working fine on local python shell.
-
Karan Purohit almost 6 yearsThat's finally solved my problem. I was looking for somehow to stop this but couldn't find any. Thanks!!
-
kawingkelvin over 3 yearsActually, plt.grid() will also remove the grid, so dont have to even type 'None'