How to display index/name for each curve when using hold on for plotting?

4 次查看(过去 30 天)
Hello,
I'm trying to plot multiple curves in a single figure, but also i wish to add small label near each curve. Any help?
Thanks
while(i<pedons(1,end))
switch true
case (pedons(i,5)==1)
figure(1)
plot(nPedons(1:100,i),1:100,'r')
xlabel('Calcium Carbonate'), ylabel('depth[cm]')
axis([0 100 0 100])
title('Soil Profile 1')
hold on
% ....... etc
end
i=i+1;
end

回答(1 个)

Chunru
Chunru 2021-12-15
while(i<pedons(1,end))
switch true
case (pedons(i,5)==1)
figure(1)
plot(nPedons(1:100,i),1:100,'r')
%%%%%%%%%%%%%%
text(nPedons(100,i), 100, "1"); % you may want to right aligned
%%%%%%%%%%%%%%
xlabel('Calcium Carbonate'), ylabel('depth[cm]')
axis([0 100 0 100])
title('Soil Profile 1')
hold on
% ....... etc
end
i=i+1;
end

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by