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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:05:50+00:00 2026-05-28T15:05:50+00:00

I have a simple problem in python and matplotlib. I have 3 lists :

  • 0

I have a simple problem in python and matplotlib.
I have 3 lists : x, y and rho with rho[i] a density at the point x[i], y[i].
All values of x and y are between -1. and 1. but they are not in a specific order.

How to make a contour plot (like with imshow) of the density rho (interpolated at the points x, y).

Thank you very much.

EDIT : I work with large arrays : x, y and rho have between 10,000 and 1,000,000 elements

  • 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-28T15:05:50+00:00Added an answer on May 28, 2026 at 3:05 pm

    You need to interpolate your rho values. There’s no one way to do this, and the “best” method depends entirely on the a-priori information you should be incorporating into the interpolation.

    Before I go into a rant on “black-box” interpolation methods, though, a radial basis function (e.g. a “thin-plate-spline” is a particular type of radial basis function) is often a good choice. If you have millions of points, this implementation will be inefficient, but as a starting point:

    import numpy as np
    import matplotlib.pyplot as plt
    import scipy.interpolate
    
    # Generate data:
    x, y, z = 10 * np.random.random((3,10))
    
    # Set up a regular grid of interpolation points
    xi, yi = np.linspace(x.min(), x.max(), 100), np.linspace(y.min(), y.max(), 100)
    xi, yi = np.meshgrid(xi, yi)
    
    # Interpolate
    rbf = scipy.interpolate.Rbf(x, y, z, function='linear')
    zi = rbf(xi, yi)
    
    plt.imshow(zi, vmin=z.min(), vmax=z.max(), origin='lower',
               extent=[x.min(), x.max(), y.min(), y.max()])
    plt.scatter(x, y, c=z)
    plt.colorbar()
    plt.show()
    

    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 have a simple problem but I am not sure how to solve it.
Simple problem, I have it solved .. but python has a million ways to
I have a problem with using Twisted for simple concurrency in python. The problem
I have a simple problem but no matter what I try I can't see
I have a very simple problem and a solution that will work, but I'm
I have a very simple problem but cannot find a nice solution. I have
I have a simple problem in Python that is very very strange. def estExt(matriz,erro):
I'm learning Python and I have a problem with this seems to be simple
I'm a beginner in Python. My problem is pretty simple. I have a string
So I have followed This guide and used a simple printing python file. Problem

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.