Hello,
I am trying to plot the legend of 3 things here: temperature data (continuous blue line), the starting point of a sit period (green asterix), end point of a sit period (red asterix). The forloop runs over 2 specified values (4 and 34).
[row2,col2] = find(start_sit_periods);
for i = col2;
t = linspace(0,(((length(temp_i1)/fs)/60)/60),length(temp_i1));
figure(1)
ee = linspace(0,((length(x_i1)/fs)/60),length(x_i1));
subplot 411
plot(ee,temp_i1)
xlabel('Time (minutes)')
ylabel('Temperature (°C)')
hold on
plot(ee(start_sit_periods(1,i)),temp_i1(start_sit_periods(1,i)),'*g')
plot(ee(end_sit_periods(1,i)),temp_i1(end_sit_periods(1,i)),'*r')
legend('Leg temperature','Start sit','End sit')
subplot 412
plot(ee,abs(x_i1))
xlabel('Time (minutes)')
ylabel('Acceleration (m/s²)')
subplot 413
plot(ee,abs(y_i1))
xlabel('Time (minutes)')
ylabel('Acceleration (m/s²)')
subplot 414
plot(ee,abs(z_i1))
xlabel('Time (minutes)')
ylabel('Acceleration (m/s²)')
end
I've tried some things, but the legend stays wrongs.
Can anyone help?
Thanks!

댓글 수: 1

darova
darova 2020년 3월 27일
Did you try put several legend after each subplot?

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

 채택된 답변

Peng Li
Peng Li 2020년 3월 27일

0 개 추천

Not quite sure what you meant by "the legend stays wrong", but please try this if my guess is correct.
figure(1)
ee = linspace(0,((length(x_i1)/fs)/60),length(x_i1));
subplot 411
p1 = plot(ee,temp_i1)
xlabel('Time (minutes)')
ylabel('Temperature (°C)')
hold on
p2 = plot(ee(start_sit_periods(1,i)),temp_i1(start_sit_periods(1,i)),'*g')
p3 = plot(ee(end_sit_periods(1,i)),temp_i1(end_sit_periods(1,i)),'*r')
legend([p1 p2 p3], {'Leg temperature','Start sit','End sit'})

추가 답변 (0개)

카테고리

태그

질문:

Sam
2020년 3월 27일

답변:

2020년 3월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by