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

  • Home
  • SEARCH
  • 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 8455455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:17:35+00:00 2026-06-10T12:17:35+00:00

I read data from binary files into numpy arrays with np.fromfile . These data

  • 0

I read data from binary files into numpy arrays with np.fromfile. These data represent Z values on a grid for which spacing and shape are known so there is no problem reshaping the 1D array into the the shape of the grid and plotting with plt.imshow. So if I have N grids I can plot N subplots showing all data in one figure but what I’d really like to do is plot them as one image.

I can’t just stack the arrays because the data in each array is spaced differently and because they have different shapes.

My idea was to “supersample” all grids to the spacing of the finest grid, stack and plot but I am not sure that is such a good idea as these grid files can become quite large.

By the way: Let’s say I wanted to do that, how do I go from:

    0, 1, 2
    3, 4, 5

to:

    0, 0, 1, 1, 2, 2
    0, 0, 1, 1, 2, 2
    3, 3, 4, 4, 5, 5
    3, 3, 4, 4, 5, 5

I’m open to any suggestions.

Thanks,

Shahar

  • 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-06-10T12:17:37+00:00Added an answer on June 10, 2026 at 12:17 pm

    The answer if you just plot is: don’t. plt.imshow has a keyword argument extent which you can use to zoom the imagine when plotting. Other then that I would suggest scipy.ndimage.zoom, with order=0, it is equivalent to repeating values, but you can zoom to any size easily or use a different order to get some smooth interpolation. np.tile could be an option for very simple zooming too.

    Here is an example:

    a = np.arange(9).reshape(3,3)
    b = np.arange(36).reshape(6,6)
    
    plt.imshow(a, extent=[0,1,0,1], interpolation='none')
    plt.imshow(b, extent=(1,2,0,1), interpolation='none')
    # note scaling is "broke"
    plt.xlim(0,2)
    

    of course to get the same color range for both, you should add vim=... and vmax keywords.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to write binary data into XML using LINQ which is being read from
I'm trying to read data from a binary file and put it into a
How should a program read and write float numbers from and into binary files
Im trying to read some data from a binary file into a buffer allocated
As part of an assignment, I need to read data from a binary file
I'm trying to read the binary data from a binary file with the code
I'm trying to display image data read in from a binary file (I have
I'm trying to read binary data from a specific offset. I write the data
I want to read both formatted text and binary data from the same iostream.
I'm trying to store some binary data obtained from read() in my buffer using

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.