필터 지우기
필터 지우기

Labelling mulitple traces on plot

조회 수: 6 (최근 30일)
Joseph
Joseph 2013년 3월 18일
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
to this
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
Joseph
Joseph 2013년 3월 18일
편집: Walter Roberson 2013년 3월 18일
Hi Thanks for the replies. c variable is to color each trace code below
c={}; for i=1:length(Kappa) c{end+1}=num2str(Kappa(i)); end
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
% set(gcf, 'PaperPositionMode', 'auto'); saveas(gcf, 'test2', 'pdf') %Save figure export_fig('C:\Users\Joseph\Documents\Geophysics\PhD\Matlab', '-pdf','-painters');
Walter Roberson
Walter Roberson 2013년 3월 18일
I adjusted my code accordingly.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2013년 3월 18일
편집: Walter Roberson 2013년 3월 18일
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
Joseph
Joseph 2013년 3월 18일
Yes, that's correct. Nan for the output of Gain if Kappa = Inf. So I guess I'll put an arbitrary large number for example 10^10 as Inf. And then how would you replace 10^10 on the text label with Inf?
Walter Roberson
Walter Roberson 2013년 3월 18일
if nn == Kappan
Kstr = 'inf';
else
Kstr = str2num(Kappa(nn));
end
text(dratio(end), G(nn,end), Kstr, 'HitTest', 'off', 'HorizontalAlignment', 'center', 'VerticalAlignment', 'bottom')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by