Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 1000
JQY Avatar asked Aug 14 '19 08:08

JQY


1 Answers

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);
like image 79
Arthur Avatar answered Sep 30 '22 21:09

Arthur