MATLAB: Legend function does not work in R2019b

bugsr2019bwindows10

The following lines of code is just a simple use of legend function.
x = linspace(0,2*pi,360);
y = sin(x);
plot(x,y);
legend('sin(x)');
But the result I get in my computer is incomplete: the legend dose not show the line of the curve.
sinx.png
I run the code in mac and it doesn't have this issue. My system is windows 10 and the version of matlab is R2019b. I don't know what causes this problem and hope someone can help me figure it out.

Best Answer

It was pointed out recently in another Question with a problem similar to yours that:
is likely the appropriate solution.
EDIT — (1 Sep 2020 at 12:22)
This turned out to be a problem with certain AMD graphics drivers. The current versions (fixed a few months ago) correct the problem that caused this. Updating the AMD graphics driver solves it.
EDIT — (2 Oct 2020 at 19:33)
See this Comment for further details.