フィルターのクリア

legend plot of subgroup lines

4 ビュー (過去 30 日間)
Eugenio Daviso
Eugenio Daviso 2017 年 10 月 30 日
回答済み: Walter Roberson 2017 年 10 月 31 日
I am preparing a gui that gives the operator the flexibility to fit n datafiles. Each datafiles contains 3 replicates. I would like to add a legend to the plot that groups the 3Xn lines and I can't get there. Thank you!
This is my code:
% code
figure(2)
hold on;
tot_f=1;
for k=1:3:(size(Data_dim,2))
color_plot(tot_f,:)=[rand(1),rand(1),rand(1)];
h{tot_f}=plot(time, Y(:,k:k+2),'Color', color_plot(tot_f,:));
xlabel('Time (s)')
ylabel('NU')
ax=gca;
ax.YLim=[0 50];
ax.XLim=[0 100];
tot_f=tot_f+1;
end
hold off;
legend(????);

採用された回答

Walter Roberson
Walter Roberson 2017 年 10 月 31 日
% code
figure(2)
hold on;
tot_f=1;
for k=1:3:(size(Data_dim,2))
color_plot(tot_f,:)=[rand(1),rand(1),rand(1)];
h{tot_f}=plot(time, Y(:,k:k+2),'Color', color_plot(tot_f,:));
desired_legends{tot_f} = ... some appropriate string
xlabel('Time (s)')
ylabel('NU')
ax=gca;
ax.YLim=[0 50];
ax.XLim=[0 100];
tot_f=tot_f+1;
end
hold off;
group_handles = cellfun(@(V) V(1), h); %get first out of each group
legend(group_handles, desired_legends)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by