MATLABの凡例関数のレイアウト(サブマップは凡例、タイル化された凡例などを共有します)



Layout Legend Function Matlab Submap Shares Legend



MATLABの凡例関数のレイアウト(サブマップは凡例、タイル化された凡例などを共有します)

MATLABを使用して描画する場合、画像に凡例が多すぎることがあります。凡例をいくつかの列(またはタイル状)に分割するか、凡例の位置、長さ、幅を変更して、次のコードを比較します。目標を達成するために、対応する変更を加えることができます。
複数のサブグラフで凡例を共有する場合は、コードのPosition値を使用して、凡例を画像全体の適切な位置に調整できます。

clear x = 1:0.1:5 figure plot(x,50*sin(x),'k',x,50*cos(x),'m',x,20*x,'g',x,x.^2,'r',x,exp(x),'p') Legend('tag1', 'tag 2', 'tag 3', 'tag 4', 'tag 5', 'location', 'northwest') figure plot(x,50*sin(x),'k',x,50*cos(x),'m',x,20*x,'g',x,x.^2,'r',x,exp(x),'p') Lgd = legend('tag 1', 'tag 2', 'tag 3', 'tag 4', 'tag 5') % Note that the end of the line is not marked with a semicolon the parameters of the legend can be displayed lgd.NumColumns = 3 lgd.Position = [0.4205 0.87 0 0] % left and right width width