Takuya Miyashita
This site
Web
Start:
*Figure全般に関するメモ [#g55908c0]
#contents
**現在のFigureの個数を取得 [#r96c1196]
-取得方法~
#codeprettify(lang-matlab){{
fh = findobj(0,'Type','Figure');
nfig = size(fh,1);
}}
1行目で生成されている Figure 全てのハンドルが fh になり,...
~
-ハンドルの再設定~
figure したのにハンドルを付け忘れた時は,上記で取得したfh...
#codeprettify(lang-matlab){{
figA = fh(1);
}}
とすれば,Figure1 固有の Figure ハンドルになる.~
~
**Figureウィンドウの表示位置変更 [#mab3e2c5]
厳密に位置を指定したいときは,Position プロパティをいじる...
#codeprettify(lang-matlab){{
p = get(gcf,'Position');
% 左端を left, 下端を bottom に,幅と高さは変更なし
set(gcf,'Position',[left bottom p(3) p(4)])
}}
Figure の Position には, [left bottom width height] が入...
上記はウィンドウのサイズはそのままに,位置だけを変える.~
他のウィンドウと重ならなければ問題ない程度であれば,moveg...
#codeprettify(lang-matlab){{
movegui(fig1,'northeast')
movegui(fig2,'southeast')
movegui('west')
}}
figure ハンドルを指定しない場合は gcf が対象.~
~
**Figureウィンドウのサイズ変更 [#xf0fb5e5]
-表示スクリーンに応じた最大サイズの取得~
subplot を使うとき,縦長や横長のグラフを作成するときなど...
使用しているディスプレイによって表示可能なサイズが変わる...
#codeprettify(lang-matlab){{
scrsz = get(groot,'ScreenSize');
maxW = scrsz(3);
maxH = scrsz(4);
}}
groot は root のグラフィックスオブジェクト.何かを格納す...
~
-ウィンドウのサイズ変更~
あとはこの表示可能な最大サイズを上回らないように,適当に...
デフォルトの大きさに対する幅の倍率を nw,高さの倍率を nh ...
#codeprettify(lang-matlab){{
figure;
p = get(gcf,'Position');
dw = p(3)-min(nw*p(3),maxW);
dh = p(4)-min(nh*p(4),maxH);
set(gcf,'Position',[p(1)+dw/2 p(2)+dh min(nw*p(3),maxW)...
}}
で設定できる.~
Position プロパティの width と height だけを変えるとウィ...
eps 形式で figure を保存するときは,PaperPosition も設定...
~
**Figureの一部を削除 [#ddde577d]
for や while でループを使って何回も描画し,軸・色・ラベル...
ラベル等はそのままに,pcolor や surf で描いたものだけ消し...
下記は,2回目以降 pcolor 以外はそのままに pcolor を書き直...
#codeprettify(lang-matlab){{
for k = 1:n
if exist('h','var'); delete(h); end; % hが変数として存...
h = pcolor(X,Y,C(:,:,k))
...
...
end
}}
~
**FigureオブジェクトからAxesの取得 [#vc80a603]
R2014 らへん以降のバージョンから,Figure や Axes,Colorba...
#codeprettify(lang-matlab){{
ax = fig.CurrentAxes;
}}
のようにすることで,
#codeprettify(lang-matlab){{
figure(fig)
ax = gca;
}}
と同様にカレント Axes を取得できる.
figure(fig) をしないのでウィンドウが邪魔にならず,functio...
End:
*Figure全般に関するメモ [#g55908c0]
#contents
**現在のFigureの個数を取得 [#r96c1196]
-取得方法~
#codeprettify(lang-matlab){{
fh = findobj(0,'Type','Figure');
nfig = size(fh,1);
}}
1行目で生成されている Figure 全てのハンドルが fh になり,...
~
-ハンドルの再設定~
figure したのにハンドルを付け忘れた時は,上記で取得したfh...
#codeprettify(lang-matlab){{
figA = fh(1);
}}
とすれば,Figure1 固有の Figure ハンドルになる.~
~
**Figureウィンドウの表示位置変更 [#mab3e2c5]
厳密に位置を指定したいときは,Position プロパティをいじる...
#codeprettify(lang-matlab){{
p = get(gcf,'Position');
% 左端を left, 下端を bottom に,幅と高さは変更なし
set(gcf,'Position',[left bottom p(3) p(4)])
}}
Figure の Position には, [left bottom width height] が入...
上記はウィンドウのサイズはそのままに,位置だけを変える.~
他のウィンドウと重ならなければ問題ない程度であれば,moveg...
#codeprettify(lang-matlab){{
movegui(fig1,'northeast')
movegui(fig2,'southeast')
movegui('west')
}}
figure ハンドルを指定しない場合は gcf が対象.~
~
**Figureウィンドウのサイズ変更 [#xf0fb5e5]
-表示スクリーンに応じた最大サイズの取得~
subplot を使うとき,縦長や横長のグラフを作成するときなど...
使用しているディスプレイによって表示可能なサイズが変わる...
#codeprettify(lang-matlab){{
scrsz = get(groot,'ScreenSize');
maxW = scrsz(3);
maxH = scrsz(4);
}}
groot は root のグラフィックスオブジェクト.何かを格納す...
~
-ウィンドウのサイズ変更~
あとはこの表示可能な最大サイズを上回らないように,適当に...
デフォルトの大きさに対する幅の倍率を nw,高さの倍率を nh ...
#codeprettify(lang-matlab){{
figure;
p = get(gcf,'Position');
dw = p(3)-min(nw*p(3),maxW);
dh = p(4)-min(nh*p(4),maxH);
set(gcf,'Position',[p(1)+dw/2 p(2)+dh min(nw*p(3),maxW)...
}}
で設定できる.~
Position プロパティの width と height だけを変えるとウィ...
eps 形式で figure を保存するときは,PaperPosition も設定...
~
**Figureの一部を削除 [#ddde577d]
for や while でループを使って何回も描画し,軸・色・ラベル...
ラベル等はそのままに,pcolor や surf で描いたものだけ消し...
下記は,2回目以降 pcolor 以外はそのままに pcolor を書き直...
#codeprettify(lang-matlab){{
for k = 1:n
if exist('h','var'); delete(h); end; % hが変数として存...
h = pcolor(X,Y,C(:,:,k))
...
...
end
}}
~
**FigureオブジェクトからAxesの取得 [#vc80a603]
R2014 らへん以降のバージョンから,Figure や Axes,Colorba...
#codeprettify(lang-matlab){{
ax = fig.CurrentAxes;
}}
のようにすることで,
#codeprettify(lang-matlab){{
figure(fig)
ax = gca;
}}
と同様にカレント Axes を取得できる.
figure(fig) をしないのでウィンドウが邪魔にならず,functio...
Page:
Edit with a page name which already exists