Conflict between 'ShowText' and 'LineStyle' in the contourf function in MATLAB R2019a?

273 views Asked by At

I'm using the code as follows. But the figures are different when I run my code in MATLAB R2014a and R2019a (in the same computer, Win7 64bit). It seems there is a conflict between 'ShowText' and 'LineStyle' in function contourf in MATLAB R2019a ? What I want is the figure with text and no line (like the figure by R2014a). How can I get that in R2019a?

for i = 1 : 10
    for j = 1 : 10
        res(i, j) = i * j;
    end
end
contourf(res, 'ShowText', 'on', 'LineStyle', 'none');

Figure using R2014a

figure by R2014a

Figure using R2019a

figure by R2019a

Figure using R2019a using contourf(res, 'ShowText', 'on') only

figure by R2019a using "contourf(res, 'ShowText', 'on') only

1

There are 1 answers

8
Arthur On

After a bit of research I found this solution with the help of undocumented MATLAB:

for i = 1 : 10
for j = 1 : 10
res(i, j) = i * j;
end
end
[c,hC] = contourf(res);
clabel(c,hC)
drawnow; % Important !
set(hC.EdgePrims(:),'Visible','off');

Which gives this result in R2017b : enter image description here

Disclaimer: This solution relies on an undocumented feature of MATLAB, the results may vary depending on your version.

R2018a

Sardar Usama came up with an alternative solution for R2018ain the comments :

%drawnow; % Important !
%set(hC.EdgePrims(:),'Visible','off');
delete(hc.EdgePrims);