2

This is a follow-up for this thread: Python : 2d contour plot from 3 lists : x, y and rho?

I essentially copied the code as shown below, but found 2 remaining issues for my application:

  1. Probably because the z data are so close to each other, I got a plot like a plot here, which doesn't seem to be correct.
  2. I also would like to draw the map with the x,y range from -50 to 50, which probably need extrapolation? Can anybody help with them? Thanks a lot!

def contour2d(xlist, ylist, zlist):

    x = np.array(xlist)
    y = np.array(ylist)
    z = np.array(zlist)    
    xi, yi = np.linspace(x.min(), x.max(), 100), np.linspace(y.min(), y.max(), 100)
    xi, yi = np.meshgrid(xi, yi)

    rbf = scipy.interpolate.Rbf(x, y, z, function='linear')
    zi = rbf(xi, yi)
    print zi

    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()

x = [0,20.506,20.506,-20.506,-20.506,41.012,41.012,-41.012,-41.012]
y = [0,-20.506,20.506,20.506,-20.506,-41.012,41.012,41.012,-41.012]
z = [1.45905, 1.45874, 1.45861, 1.45914, 1.45909, 1.4584, 1.45793, 1.45883, 1.45863]
contour2d(x,y,z)
Community
  • 1
  • 1
lignin
  • 439
  • 1
  • 5
  • 11

0 Answers0