【MATLAB】よく使う凡例の設定方法
毎回よく使う割によく忘れるので覚書。
①DisplayNameを使う方法
LineプロパティのDisplayNameを使ってセットする方法
a(:,1)=sin(t); a(:,2)=cos(t); h = plot(a); set(h,{'DisplayName'},{'Sine','Cosine'}')
これだと最大値にマークをプロットした場合などにも凡例を付けることになって
使えない
②lenged(lineハンドル配列 , 凡例文字列配列)
これが便利。
h = [];
h = [h , plot(....)];
h = [h , plot(....)];
legend(h , legendNameList);