figureの重ね合わせ

11 views (last 30 days)
ryo
ryo on 5 Feb 2025
近似プロットによって得たfigureが別々に2つあります。これらを重ね合わせて1つのfigureにしたいのですがどういった方法があるでしょうか。
また, 近似プロットによって作成したfigureの背景を透明にできる方法も教えていただきたいです。

Answers (1)

交感神経優位なあかべぇ
Edited: 交感神経優位なあかべぇ on 9 Feb 2025
figureの座標軸内にあるデータのParentプロパティの値を任意の座標軸に置き換えることで、データを重ね合わせることができます。
% サンプルデータの作成
figure;
scatter(rand(10,1),rand(10,1));
figure;
scatter(rand(10,1),rand(10,1),'MarkerEdgeColor','r');
hold on;
plot([0,1],[0,1]);
drawnow();
haxes = findobj('type', 'axes');% 現在表示している座標軸をすべて取得
set(haxes(2).Children, 'Parent', haxes(1));% 2番目の座標軸の子オブジェクト(ラインや点のデータ)をすべて1番目の座標軸に変更
% 空の座標軸とデータをひとつにまとめた座標軸ができる。
また、figure(ウィンドウ画面)は透明にできません。
座標軸であれば、Colorプロパティの4要素目の値を0に設定すると透明になります。
figure;
scatter(rand(10,1),rand(10,1));
haxes = gca;
haxes.Color = [0.5,0.5,0.5,0];% Colorの4要素目は透明度設定

Categories

Find more on グラフィックス パフォーマンス in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!