bakas
bakas

Reputation: 323

Increase the display size of image in matplotlib

I have a set of images on my system, which I am loading into my Jupyter notebook and then trying to display them all together using matplotlib.

The code is as follows:

for i,k in enumerate(image_list):
    fig = plt.figure("Results: %s" % (methodName))
    fig.suptitle("Correlation", fontsize = 10)

    ax = fig.add_subplot(1, len(image_list), i + 1)
    plt.imshow(images[k])
    plt.rcParams["figure.figsize"] = [16,9]
    plt.axis("off")

plt.show()

Here image_list is a list containing image names, while images is a dictionary which contains image name as key and image as value.

When I display the 20 images together, the displayed images are very small in size and I am not able to increase the height or width of the image.

I tried the figsize in plt.figure as well as in plt.rcParams but both do not work.

Could someone help me with this problem?

Upvotes: 1

Views: 7232

Answers (1)

Ujjwal Dash
Ujjwal Dash

Reputation: 823

you can use figure(figsize=(1,1)) would creat an inch-by-inch image

Here is a small example

from matplotlib.pyplot import figure
import matplotlib.pyplot as plt

figure(num=None,figsize=(100,100),dpi=80,facecolor='w',edgecolor='k')
a=[1,5,7,9]
b=[4,6,8,7]
plt.plot(a,b)
plt.show()

dpi=80 will show figure of 80 pixel

OUTPUT enter image description here

Upvotes: 3

Related Questions