Adding legend to a plot from an array

Ive got iD directories, iF files per directory and iS data sets per files. To extract the data I build an array dataset(:,iD,iF,iS) and also build a legend string with the corresponding names of the directory,file and data set just like legStr{iD,iF,iS}. Then I loop over the directories times the files times the data sets and plot it all in one figure. How can I use my legStr cell array to create a legend on this figure ?

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 6 月 20 日
編集済み: Azzi Abdelmalek 2015 年 6 月 20 日

0 投票

lengend(legStr)

3 件のコメント

Moiz
Moiz 2015 年 6 月 20 日
That works only if legStr is a 1-D cell array of strings. In this case it is 3-D. Hence I use reshape just like legStr = reshape(legStr,nDir*nFiles*nDataSets,1). However this ends up becoming something like dir1/file1/set1, dir2/file1/set1, dir1/file2/set1, dir2/file2/set1 and so on instead of dir1/file1/set1, dir1/file1/set2, dir1/file2/set1, dir1/file2/set2 and so on.. i.e., the reshaping does not follow the same order as the data gathering - hence this would mess up the legend on the figure.
Azzi Abdelmalek
Azzi Abdelmalek 2015 年 6 月 20 日
use
legend(legStr(:))
Tamil
Tamil 2024 年 4 月 20 日
Enter legend one space with starnames. Legend (starnames)

サインインしてコメントする。

その他の回答 (1 件)

Kishor
Kishor 2022 年 12 月 19 日

0 投票

Add a legend to plot using the array starname

カテゴリ

タグ

質問済み:

2015 年 6 月 20 日

コメント済み:

2024 年 4 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by