Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Continuous Cyclic Color Table Plot

Please login with a confirmed email address before reporting spam

Hi,

I am trying to visualize the phase of an acoustic mode. I calculate the phase of my pressure field via: atan2(real(p),imag(p)) where p is the acoustic pressure.

I rescale the phase to a -180 to +180 degree interval and plot it as a surface using the cyclic colortable. The result looks fine, except that there are discontinuities in the surface plot where the phase jumps from -180 (red) to +180 (red) between cells. The color of the surface plot changes through all of the intermediate values producing 1 cell wide "rainbow bands" throughout the surface plot.

Is there a way to make a continuous cyclic color table plot? i.e. one where between cells with -180 (red) and +180 (red) the color stays red?

thanks

1 Reply Last Post 21 lug 2016, 11:55 GMT-4
Henrik Sönnerlind COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 21 lug 2016, 11:55 GMT-4
Hi,

The problem lies in the interpolation between -180 and 180 within the elements where the jump is. You could try to force the value to be 180 where the phase has a large gradient.

Here is a suggestion in that direction (not tested thogh)

Create three variables:

phase: atan2(real(p),imag(p))*180/pi
phase_gradient: sqrt(d(phase,x)^2+d(phase,y)^2+d(phase,z)^2)
phase_cyclic: if(phase_gradient>100,180,phase)

The limit on the gradient (here 100) must of course be tuned to your actual spatial phase gradient so that it only captures the jumps.

Now you can plot phase_cyclic, and hopefully the results should look better.

Regards,
Henrik


Hi, The problem lies in the interpolation between -180 and 180 within the elements where the jump is. You could try to force the value to be 180 where the phase has a large gradient. Here is a suggestion in that direction (not tested thogh) Create three variables: phase: atan2(real(p),imag(p))*180/pi phase_gradient: sqrt(d(phase,x)^2+d(phase,y)^2+d(phase,z)^2) phase_cyclic: if(phase_gradient>100,180,phase) The limit on the gradient (here 100) must of course be tuned to your actual spatial phase gradient so that it only captures the jumps. Now you can plot phase_cyclic, and hopefully the results should look better. Regards, Henrik

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.