Legend Entries for Contours

3 views (last 30 days)
Wayne Falk
Wayne Falk on 20 Jun 2016
Commented: Benjamin Brennan on 23 Aug 2017
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?

Answers (1)

Chad Greene
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
Benjamin Brennan
Benjamin Brennan on 23 Aug 2017
What if your contour plot is a filled contour plot?

Sign in to comment.

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!