Effacer les filtres
Effacer les filtres

Text label in plot/graph

2 vues (au cours des 30 derniers jours)
premraj
premraj le 2 Sep 2011
Hi, I want to place a formatted text on the right side of my contour plot.
sample text is shown below :
Rotation: 0 Elevation: 90 Orientation: 0 Spec Range: 241.9877
This text value represents the parameters of the graph plotted.So whenever somebody resized the figure , text position shall be adjusted so that the text won't overlap with the graph.
Can anyone help me to sove this issue??

Réponse acceptée

Oleg Komarov
Oleg Komarov le 2 Sep 2011
Contour example:
[X,Y] = meshgrid(-2:.2:2,-2:.2:3);
Z = X.*exp(-X.^2-Y.^2);
[C,h] = contour(X,Y,Z);
set(h,'ShowText','on','TextStep',get(h,'LevelStep')*2)
colormap cool
% Place text label
text(1.9,2.5,'Rotation: 0 Elevation: 90 Orientation: 0 Spec Range: 241.9877',...
'Horiz','right','Vert','Bottom')
Alternatively, vertically stacked labels:
lbl = {'Rotation', 'Elevation', 'Orientation', 'Spec Range';
0 , 90 0 241.9877};
cs = sprintf('%-11s: %10.4f\n',lbl{:});
text(1.9,2.9,cs,'FontN','FixedWidth','Horiz','right','Vert','top')
  1 commentaire
premraj
premraj le 2 Sep 2011
thanks oleg for ur response!!!It worked!!!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by