2

I want to plot phase properly in a 2d image using matlibplot and in particular the cyclic colormaps. I however get a weird line that I want to get rid of. Can anyone help me, I think there might be something wrong in the code. This is my code and the output:

def vortex(x,y,mux,muy):
    return np.angle((x-mux)+1j*(y-mux))

x=np.linspace(0,1,101)
y=np.linspace(0,1,101)
xx, yy = np.meshgrid(x, y)

z=vortex(xx,yy,0.5,0.5)

pos=plt.imshow(z,'hsv')
plt.colorbar(pos)
plt.show()

This is the output image: you can see a line through the center:
This is the output image: you can see a line through the center

Pranav Hosangadi
  • 23,755
  • 7
  • 44
  • 70
user392269
  • 21
  • 1

1 Answers1

0

I think its just a typo

def vortex(x,y,mux,muy): return np.angle((x-mux)+1j*(y-muy))

The line is because you have a branch cut in the function, and so the values go from -pi to pi from one row to the next. You can see this better if you remove the 'hsv' colour style

Nadeem
  • 1