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 8335967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:50:14+00:00 2026-06-09T03:50:14+00:00

I am trying to plot some HDF data in matplotlib. After importing them using

  • 0

I am trying to plot some HDF data in matplotlib. After importing them using h5py, the data is stored in a form of array, like this:

array([[151, 176, 178],
       [121, 137, 130],
       [120, 125, 126])

In this case, x and y values are just the indexes of the array’s fields, while z value is the value of specific field. In the (x,y,z) form it would look like:

(1,1,151)
(2,1,176)
(3,1,178)
(1,2,121)
...

and so on.

Is there an easy way to do a surface plot from this kind of data? I know I can change this to (x,y,z) tuples by iterating all over the array, but maybe it is not needed?

  • 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-09T03:50:16+00:00Added an answer on June 9, 2026 at 3:50 am

    If you want a 3-d surface plot, you have to create the meshgrid first. You can try:

    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    import numpy as np
    
    X = np.arange(1, 10)
    Y = np.arange(1, 10)
    X, Y = np.meshgrid(X, Y)
    R = np.sqrt(X**2 + Y**2)
    Z = np.sin(R)
    fig = plt.figure()
    ax = fig.gca(projection='3d')
    surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='hot', linewidth=0, antialiased=False)
    ax.set_zlim(-1.01, 1.01)
    
    fig.colorbar(surf, shrink=0.5, aspect=5)
    plt.show()
    

    which will generate,
    enter image description here

    However, if the only relevant information is in the z-values, you can simply use imshow. Here, z-values are represented by their color. You can achieve this by:

    im = plt.imshow(Z, cmap='hot')
    plt.colorbar(im, orientation='horizontal')
    plt.show()
    

    Which will give,

    enter image description here

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

Sidebar

Related Questions

I'm using GD to plot some simple charts from array point data.. Trying to
I am trying to plot some data using pylab scatter function. I'm using pylab.scatter(X,
I'm trying to plot some data into a histogram using pyplot.hist as such: hst
I am using matplotlib and I'm finding some problems when trying to plot large
I am using the MSChart Control to plot some data but I would like
I am trying to plot some test data (show at the end of this
I am trying to plot some one-dimensional data onto a 2-D plot in MATLAB.
So I'm trying to create some graphs using Core Plot, but for the following
I am trying to create plot some push pins on map using GeoCoordinate as
I'm currently trying to use the core-plot library to graph some data I get

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.