Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6810713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:14:21+00:00 2026-05-26T20:14:21+00:00

I want to display an image (say 800×800) with Matplotlib.pyplot imshow() function but I

  • 0

I want to display an image (say 800×800) with Matplotlib.pyplot imshow() function but I want to display it so that one pixel of the image occupies one pixel on the screen (zoom factor = 1, no shrink, no stretch).

I’m a beginner, so do you know how to proceed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:14:21+00:00Added an answer on May 26, 2026 at 8:14 pm

    Matplotlib isn’t optimized for this. You’d be a bit better off with simpler options if you just want to display an image at one-pixel-to-one-pixel. (Have a look at Tkinter, for example.)

    That having been said:

    import matplotlib.pyplot as plt
    import numpy as np
    
    # DPI, here, has _nothing_ to do with your screen's DPI.
    dpi = 80.0
    xpixels, ypixels = 800, 800
    
    fig = plt.figure(figsize=(ypixels/dpi, xpixels/dpi), dpi=dpi)
    fig.figimage(np.random.random((xpixels, ypixels)))
    plt.show()
    

    Or, if you really want to use imshow, you’ll need to be a bit more verbose. However, this has the advantage of allowing you to zoom in, etc if desired.

    import matplotlib.pyplot as plt
    import numpy as np
    
    dpi = 80
    margin = 0.05 # (5% of the width/height of the figure...)
    xpixels, ypixels = 800, 800
    
    # Make a figure big enough to accomodate an axis of xpixels by ypixels
    # as well as the ticklabels, etc...
    figsize = (1 + margin) * ypixels / dpi, (1 + margin) * xpixels / dpi
    
    fig = plt.figure(figsize=figsize, dpi=dpi)
    # Make the axis the right size...
    ax = fig.add_axes([margin, margin, 1 - 2*margin, 1 - 2*margin])
    
    ax.imshow(np.random.random((xpixels, ypixels)), interpolation='none')
    plt.show()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display an image at 'true size' in my application. For that
I have a 16 bit grayscale image that I want to display using WPF
I have a splash image that I want to display when the app is
I want to display images in WPF, but using an actual image, instead of
Let's say I have a loading indicator image, I want it to display nicely
Say I want to display an image, with some hot links, rollover, and similar.
I want to display image using base64 encoding in IE using GWT If it
I want to display an image within a scroll area. The view port of
I want to display .jpg image in an Qt UI. I checked it online
If I want to display an image in my webpage and its src is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.