0

I am having a bit of trouble with my output of my code to produce a 2d contour plot. I show the result below. enter image description here

As may be seen, the y axis is greatly distorted, and yet my code seems to have nothing within it which should cause this. My code is shown below:

#vel_array, Rpl_array, and mass_loss_values are all some lists with the same length, but which I have not given here. 

# Set up a regular grid of interpolation points
xi, yi = np.linspace(min(np.array(vel_array)), max(np.array(vel_array)), 100), np.linspace(min(np.array(Rpl_array)), max(np.array(Rpl_array)), 100)
xi, yi = np.meshgrid(xi, yi)

# Interpolate
rbf = Rbf(np.array(vel_array), np.array(Rpl_array), np.array(mass_loss_values), function='cubic')
zi = rbf(xi, yi)
mass_loss_values=np.array(mass_loss_values)
vel_array=np.array(vel_array)
Rpl_array=np.array(Rpl_array)
plt.imshow(zi, vmin=min(mass_loss_values), vmax=max(mass_loss_values), origin='lower',
           extent=[min(vel_array), max(vel_array), min(Rpl_array), max(Rpl_array)])
plt.scatter(np.array(vel_array), np.array(Rpl_array), c=np.array(mass_loss_values))
plt.colorbar()
plt.show()  

I would apprecaite assistance.

inquiries
  • 385
  • 2
  • 7
  • 20

1 Answers1

1

You have an x range of 40000, but a y range of just 1000.

imshow by default sets the aspect ratio to equal, resulting in the very large aspect ratio (40:1). Try setting aspect='auto' as an option in your imshow command:

plt.imshow(
    zi, 
    vmin=min(mass_loss_values), 
    vmax=max(mass_loss_values),
    origin='lower', 
    extent=[min(vel_array), max(vel_array), min(Rpl_array), max(Rpl_array)], 
    aspect='auto'
    ) 
tmdavison
  • 64,360
  • 12
  • 187
  • 165