Filter löschen
Filter löschen

How does the contour plot with R2014b work?

4 Ansichten (letzte 30 Tage)
Janne am 25 Nov. 2014
Kommentiert: Mike Garrity am 20 Aug. 2015
Hi there,
I have a script which worked perfectly in the version R2014a and now I have some issues. First, my legend displays the wrong colours for the contour plot and secondly, I cannot change the clabel properties. This is a simplified Code without the Clabel properties:
>> contour(MVD_cal,'Color','r')
>> hold on
>> contour(LWC_cal,'Color','b')
>> legend('MVD','LWC')
The plot itself is correct, but the legend displays both times Purple, Green and Yellow (See image at the buttom). How do I have to change the Code to get also a red and a blue indication in the legend??
To the second problem: I understand, that clabel works different now. I have the following code:
clabel( C_LWC,h_LWC ,'LabelSpacing',250);
clabel( C_LWC ,'color','w',...
'BackgroundColor',[0.2157 0 0.3207],...
'FontName', strFontName, ...
'FontUnit', strFontUnit, ...
'FontSize', iFontSize*0.8, ...
'FontWeight', strFontWeight, ...
'Interpreter', strInterpreter);
I would like to have the format of the second part (so the box, the color, the style), but on the position and also following the graph like in the first part (LabelSpacing). How do I do that now, that I have to use C_LWC,h_LWC for LabelSpacing and only C_LWC for the formating?
Thanks a lot!

Antworten (1)

Rob Comer
Rob Comer am 5 Jun. 2015
You can avoid the problem with the clabel function, which is present in both R2014b and R2015a, by using one of the workarounds available here: After downloading and installing the appropriate workaround, you will be able to control the appearance of contour label text with commands such as this:
[C,h] = contour(peaks);
clabel(C,h,'BackgroundColor','yellow','EdgeColor','magenta', ...
The workaround will enable you to specify 12 properties that affect the appearance of contour labels. This includes all the properties shown in your code above, except for FontUnits. (Instead of setting FontUnits, you'll need to set the value of FontSize in units of 'points'.)
  2 Kommentare
Jason am 20 Aug. 2015
you didn't respond to the original question on why in 2014b contour plot color in the legend is wrong. Why?
Mike Garrity
Mike Garrity am 20 Aug. 2015
We've been fiddling with how legend represents contours to try to make it better, but the new version certainly didn't do very well in this case. Could you send this to the support team to make sure they know about it. I don't think I've seen a bug report for this one.

Melden Sie sich an, um zu kommentieren.


Mehr zu Contour Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by