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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:30:09+00:00 2026-06-17T14:30:09+00:00

I have small sets of irregularly-spaced data taken at various points over a circular

  • 0

I have small sets of irregularly-spaced data taken at various points over a circular area, in polar format. I need to do interpolation to get the data on a regularly-spaced grid, and then I’d like to plot them using a contour plot.

I’ve managed to do the interpolation and plot the result, but I have to convert from polar to rectangular coordinates to do the interpolation, and I get artifacts on the polar plot when I convert the data back to polar coordinates.

The following code demonstrates what I have so far, and plots the data on a polar and rectangular plot:

import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import Rbf

# inputs as 1D arrays
r = np.array([0, 1, 1, 1, 1, 2, 2, 2, 2])
theta = np.radians(np.array([0, 90, 180, 270, 0, 90, 180, 270, 0]))
# z = f(theta, r)
z = np.array([8, 7, 6, 4, 5, 2, 2, 2, 2])

# convert to rect
x = r * np.cos(theta)
y = r * np.sin(theta)

# create RBF for smoothing
rbf = Rbf(x, y, z)

# create grid to smooth over
xi, yi = np.mgrid[-2:2:10j, -2:2:10j]
# smooth
zi = rbf(xi, yi)

# convert back to polar
ri = np.sqrt(xi*xi + yi*yi)
ti = np.arctan2(yi, xi)

# polar plot
fig = plt.figure()
ax = plt.subplot(121, polar=True)
cax = ax.contour(ti, ri, zi, 10, linewidths=0.5, colors='k')
cax = ax.contourf(ti, ri, zi, 10, cmap=plt.cm.Spectral)
ax.set_rmax(2)

# rect plot
ax = plt.subplot(122)
cax = ax.contour(xi, yi, zi, 10, linewidths=0.5, colors='k')
cax = ax.contourf(xi, yi, zi, 10, cmap=plt.cm.Spectral)

plt.show()

The remaining issues are:

  • Can I fix the contour line artifacts?
  • Does Scipy provide a more appropriate interpolation algorithm that works for such small datasets containing polar coordinates?
  • 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-17T14:30:10+00:00Added an answer on June 17, 2026 at 2:30 pm

    You may want to read this as well, but as far as the contour plot in polar coordinates is concerned, matplotlib expects a regularly meshed array in the radius and angle, so you could plot all nicely doing:

    # polar plot
    ri, ti = np.mgrid[0:2:100j, 0:2*np.pi:100j]
    zi = rbf(ri*np.cos(ti), ri*np.sin(ti))
    
    fig = plt.figure()
    ax = plt.subplot(121, polar=True)
    cax = ax.contour(ti, ri, zi, 10, linewidths=0.5, colors='k')
    cax = ax.contourf(ti, ri, zi, 10, cmap=plt.cm.Spectral)
    ax.set_rmax(2)
    
    # rect plot
    xi, yi = np.mgrid[-2:2:100j, -2:2:100j]
    zi = rbf(xi, yi)
    
    ax = plt.subplot(122, aspect='equal')
    cax = ax.contour(xi, yi, zi, 10, linewidths=0.5, colors='k')
    cax = ax.contourf(xi, yi, zi, 10, cmap=plt.cm.Spectral)
    plt.show()
    

    enter image description here

    I am a little surprised by your use of Rbf. What exactly are you tring to do and why are you using that interpolator?

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

Sidebar

Related Questions

I have some small sets of data from the database (mysql) who are seldom
I have a legacy app that used to use small(er) sets of data. Currently
I have a series of data points (tuples) in a list with a format
We have service that's working with small to large sets of data (document generation),
I have a small script that sets multiple cookies, they all have this format
I have small class called 'Call' and I need to store these calls into
I have a situation here where I need to distribute work over to multiple
Possible Duplicate: Performing Join Operation in Java, on a small sets of data retrieved
I have a small script which makes an li element click-able and sets the
I have some large data sets (numeric and textual) and as I'm studying and

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.