The transparency of patch in legend changes when the legend is updated in the plot browser in the figure. How can I stop it?
1 view (last 30 days)
Show older comments
Romilde Kotze
on 1 Dec 2017
Commented: Romilde Kotze
on 5 Dec 2017
Why does the patch transparency of a filled plot change when I update the legend in the plot browser?
I would like to plot my curves and then hide/delete some of them and then update the figure and legend using the features in the plot browser. Unfortunately,the patch transparency for my one curve changes if I refresh or delete and reinsert the legend. Also, I notice the text (latex) for the one curve doesn't come out properly unless I reinsert the legend directly in the plot browser. Why? ( I need some of the text in 'latex' and others in 'tex')
I also don't understand why I get this error 'Error using matlab.graphics.primitive.Data/set...There is no interpreter property on the Line class.'
Here's a sample of my code (note my actual script has a lot more line curves and a at least 2 filled curves). I am using Matlab 2016b.
Thanks
0 Comments
Accepted Answer
Elizabeth Reese
on 4 Dec 2017
Any time the legend creates new patches, they will default to the non-transparent FaceAlpha. Using the syntax to return the LegIcon set is not recommended in the documentation as it does not support all graphics features and may not automatically update as you add or remove data series from the axes. To address this, MathWorks is working on an update to the legend so that the patches in the legend are the same FaceAlpha as their corresponding lines. This update is being considered for a future release of MATLAB.
As to the error you are seeing, that is because LegIcon includes the line, text, and patch objects that are children of the legend. The set command is trying to set the interpreter for each of these objects, but Line objects do not have this property. Try changing this set command to:
set(findobj(LegIcon,'type','text'),'interpreter', 'latex', 'fontsize', 8);
More Answers (0)
See Also
Categories
Find more on Legend in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!