Labelling mulitple traces on plot
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
How would you go about automatically labeling each trace on a plot for the case where the values are automatically generated in a for loop
from this
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/151738/image.png)
to this
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/151740/image.png)
The labels either sitting on top of each trace or adjacent outside the plot preferably with transparent background.
my code:
for nn = 1:Kappan
cc = jet(Kappan);
figure(1)
loglog(dratio,G(nn,:),'.-','color',cc(nn,:))
grid on
xlabel('Length / Diameter')
ylabel('Gain')
legend('boxoff'),legend(c,'location','NorthWest')
hold on
end
hold off
Thank You,
Joe
3 commentaires
Réponse acceptée
Walter Roberson
le 18 Mar 2013
Modifié(e) : Walter Roberson
le 18 Mar 2013
figure(1)
for nn = 1:Kappan
loglog(dratio, G(nn,:), 'kd', 'LineStyle', 'none');
if nn == 1
grid on
xlabel('Length / Diameter')
ylabel('Gain')
hold on
end
text(dratio(end), G(nn,end), str2num(Kappa(nn)), 'HitTest', 'off', 'HorizontalAlignment', 'center', 'VerticalAlignment', 'bottom')
end
hold off
We need more information in order to generate the "wait" line and the infinity trace.
6 commentaires
Walter Roberson
le 18 Mar 2013
if nn == Kappan
Kstr = 'inf';
else
Kstr = str2num(Kappa(nn));
end
text(dratio(end), G(nn,end), Kstr, 'HitTest', 'off', 'HorizontalAlignment', 'center', 'VerticalAlignment', 'bottom')
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Labels and Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!