subplot などで作成した複数の Axes に対して、一つの共通した legend( 凡例)を作成するにはどうすればよいですか?
Mostrar comentarios más antiguos
subplot 関数を使って、Figure 上に複数の Axes を表示しています。
表示しているデータは、すべての Axes で共通した内容のため、legend (凡例)は、一つだけ表示させたいのですが、以下のように実行すると、一番下の Axes だけサイズが揃いません。
f = figure;
c = categorical({'January','July'});
subplot(3, 1, 1)
bar(c,rand(2, 2))
subplot(3, 1, 2)
bar(c,rand(2, 2))
subplot(3, 1, 3)
bh = bar(c,rand(2, 2));
% legend での表示名
bh(1).DisplayName = string(c(1));
bh(2).DisplayName = string(c(2));
legend('show','Location','southoutside') % 最下段の下に凡例を表示

tiledlayout や nexttile 関数で Axes を複数配置した場合も、legend の位置をバランスよく調整できません。
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Legend en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!