MATLAB Answers


How do I change the labels values under contour plot (CONTOUR and CLABEL)?

Asked by Ricko Lase on 13 Aug 2018 at 6:02
Latest activity Commented on by Ricko Lase on 16 Aug 2018 at 23:00

I have a simulation that produces range of numbers which I plotted into Contour plot. The problem is, these values are not linear in respect to X or Y axis and visually it is better to plot them as decibel (dB). See below

Related Code:

[C,h] = contour(XPOS_VECT,YPOS_VECT,Values,50,'ShowText','on');
set(gca,'Clim',[150 210]);

While it is easier to see visually, non technical people (my target audience of this plot) might misunderstand the values as they are described in dB rather than linear. Therefore, I would like my contour plot to have pattern in dB progression (as shown in the figure above) while the label shows linear number associated with each dB number. Can someone provide any insight or help for this? Thanks beforehand


Sign in to comment.




1 Answer

Answer by jonas
on 13 Aug 2018 at 7:16
Edited by jonas
on 16 Aug 2018 at 8:10
 Accepted Answer

Turns out if you do not pass the contour handle to clabel, then clabel outputs the labels, which you can easily change. If you instead add the contour handle, then the labels are stored in the contour handle's hidden property 'TextPrism'.

Here's an example where the labels are increased by a factor of two using the hidden property:

for idx = 1 : numel(labels)


Show 1 older comment

Added some code using the undocumented features (thanks Walter). It puts the labels inside the contour lines per default.

EDIT: I accidentally removed the first approach, however the new one is better anyway!

Thanks Jonas and Walter, your combined responses managed to solve my problems. Much appreciated

Sign in to comment.