2

I have a code like this

[Cp hp] = contourf(log2(S_pr),log2(C_pr),ClassRateMatr_pr);

clabel(Cp,hp,'LabelSpacing',150,'BackgroundColor',[1 1 1],'fontsize',16);

Which gives me this enter image description here

As you can see the labels overlap such a way that it's impossible to read,

How can I randomly place them or use other trick?

Thanks,

Rashid
  • 4,326
  • 2
  • 29
  • 54

1 Answers1

1

I'm afraid there is no convenient way to do what you want.

If you can't manage to get the desired result using 'LabelSpacing', there is probably no other easy way to achieve properly set labels automatically and reliable.

I'd recommend to do it manually:

[C,h] = contour(X,Y,Z,obj_Z);
t = clabel(C,h,'manual','LabelSpacing',2000,'FontSize',8)

when now the figure window pops up, a crosshair appears and you can click on every single contour line to exactly specify where to place the label. With some practice you get it done quite fast. I hope you don't have a hundreds of plots like this ;) Just prepare everything before you print your final plot and set it to 'manual' as a last step.

Robert Seifert
  • 25,078
  • 11
  • 68
  • 113
  • It's what I've been looking for, thanks, Actually I have only 2 plots but I needed them to be clean! – Rashid Aug 16 '14 at 17:04