Legend Entries for Contours
3 views (last 30 days)
Show older comments
In R2014a I have code that created a contour plot of a 50% and 90% quantile using the following
>> vec=[.9,.5]; % Reliability contours to plot
>> [mC hC] = contour(exp(Ymle),exp(Xmle),Zmle,vec,'ShowText','off');
>> set(get(get(hC,'Annotation'),'LegendInformation'), 'IconDisplayStyle','Children');
>> legend('90%', '50%');
>> legend('show');
>> set(gca, 'XScale', 'log');
The plot I get is what I wanteded with two separate legend entries:

But when I try to do these same commands in R2014b or higher get:
Warning: Ignoring extra legend entries.
> In legendHGUsingMATLABClasses>set_children_and_strings (line 650)
In legendHGUsingMATLABClasses>make_legend (line 313)
In legendHGUsingMATLABClasses (line 241)
In legend (line 118)
And on the plot there is only one entry for the legend

How can I get the first version (separate legend entries for each contour) in R2014b and higher?
0 Comments
Answers (1)
Chad Greene
on 20 Jun 2016
This is somewhat clunky, but you could convert the contour matrix to xyz data with C2xyz and plot each line separately using plot.
1 Comment
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!