greole
greole

Reputation: 4771

displaying imported figure has poor resolution

I am trying to display imported figures in a matplotlib subplot inside a ipython notebook,

import matplotlib.pyplot as plt
import matplotlib.image as mpimg
matplotlib.use('Agg')
import numpy as np
img = mpimg.imread("image.png",format="png")
f, axarr = plt.subplots(1,2)

axarr[0].imshow(img)
axarr[1].imshow(img)

which kind of works but the displayed resolution is pretty poor. What am I missing here? When I use

from IPython.display import Image
displayImage(img)

it looks much better, but then I cant place multiple figures in row.

enter image description here

Upvotes: 0

Views: 968

Answers (1)

greole
greole

Reputation: 4771

Somehow increasing the standard figsize before reading the figure did the trick.

import matplotlib.pyplot as plt
plt.rcParams.update({'figure.figsize': (30,30)})
import matplotlib.image as mpimg
matplotlib.use('Agg')
import numpy as np
img = mpimg.imread("image.png",format="png")
f, axarr = plt.subplots(1,2)

axarr[0].imshow(img)
axarr[1].imshow(img)

Upvotes: 2

Related Questions