How to plot a remote image from http url using Matplotlib?

MatplotlibPythonData Visualization

To plot a remote image from an http URL, we can use io.imread() method to read an URL and take the following steps −

  • Set the figure size and adjust the padding between and around the subplots.
  • Load an image from an http URL
  • Use imshow() method to display data as an image, i.e., on a 2D regular raster.
  • Turn off the axes.
  • To display the figure, use show() method.

Example

from skimage import io
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

f = "http://matplotlib.sourceforge.net/_static/logo2.png"
a = io.imread(f)

plt.imshow(a)
plt.axis('off')

plt.show()

Output

raja
Published on 03-Jun-2021 09:17:40
Advertisements