Why does WHITEBG not complement my LEGEND text color in MATLAB 7.0 (R14)?

2 views (last 30 days)
When I execute the following code,
plot(1:10);
legend('Test');
I can see both the plot and the legend text as expected. The line plot is displayed in blue color and the legend text is in black. Now, when I issue the following command:
whitebg
This command changes the axes background color so that it complements the colors in the current figure. In this case the line color complements to yellow and the legend's text color complements to white. When I repeat the PLOT command, it replaces the existing plot and generates a new plot with the line color that is still yellow (in order to be visible against the background complemented by the WHITEBG command issued earlier). This is expected. However, if I issue the LEGEND command again, the text in the legend box is invisible. I expect the text to be displayed in white in order to be visible against the background.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This bug has been fixed in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:
A bug in MATLAB 7.0 (R14) prevents legend text from being displayed properly when the WHITEBG is used.
To work around this issue, you need to explicitly set the 'TextColor' property of the legend after plotting the legend, as illustrated in the following code:
whitebg % Assuming this statement now complements the axes color to black
plot(1:10)
hLeg = legend('data');
set(hLeg,'TextColor',[1 1 1])

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!