When working with images, it’s often convenient to hide the axis:
plt.imshow(image)
plt.axis("off");
But for many images it would be more convenient to have
plt.rcParams['axis'] = 'off'
in the beginning of a script, especially in Jupyter notebook context.
Does this exist?
You may want to consider using figimage
instead (matplotlib.pyplot.figimage — Matplotlib 3.5.2 documentation) but that does not resample (so a 1kx1k image will make a 10inx10in figure at 100dpi).
Thanks for the suggestion, I’ve just tried figimage
, but that is a bit inconvenient to use.
Is there any other way to set the default behavior to plt.axis("off")
?
One idea is adding the three lines:
def imshow(img):
plt.imshow(img)
plt.axis("off")
imshow(img)
but this is not pretty, and I’d like to still call images with plt.imshow(img)
.
In the python animation library manim there is a set_default
method that allows the following:
Text.set_default(color=GREEN)
Circle.set_default(color=YELLOW)
Circle.set_default(stroke_width=20)
t = Text("Hello World")
c = Circle()
maybe there is something similar possible in Matplotlib for hiding axis?