0

I am facing a problem with the contourf function.

Here is my code, which is part of a gui (hence the handles):

contourLevels = (1:0.5:60);
axes(handles.firstcontouraxes);
contourf(Y,fliplr(X),z1, contourLevels,'edgecolor','none'); 
axis equal
colormap(cmap);
colorbar();
title('Paramater a plot');
set(gca,'TickDir','out','box','off');

Yielding the following plot:

contour plot

As you can see, there is a red edge at the interface between the sample and air (air is when the value is 0 and appear white).

I suspect that contourf is trying to smooth my data, as the white area (air) is made of 0s and then we suddenly have relatively larger values at the sample-air interface.

Is it possible to remove this feature?

Mosawi
  • 197
  • 2
  • 16
  • 4
    Make the white `NaN` or remove the interpolation (`shading flat` I think). – Ander Biguri Apr 07 '21 at 12:44
  • Can you reproduce the issue with some arbitrary values that can be shared in your question? – If_You_Say_So Apr 07 '21 at 13:13
  • 2
    _the white area (air) is made of 0s_ => according to the colorbar, isn't zero black? – If_You_Say_So Apr 07 '21 at 13:15
  • @Person.Woman.Man.Camera.TV - I am starting from 1 (as can be seen in "contourLevels = (1:0.5:60);". Its quite complicated to reproduce as it is a gui, but will try and share if I could. – Mosawi Apr 07 '21 at 13:33
  • 1
    @AnderBiguri, Thank you. Replacing the 0 with NaN fixed the problem. Shading flat did not have an effect – Mosawi Apr 07 '21 at 13:37

0 Answers0