座標軸をスクロールさせるには、どのようにすればいいですか?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
座標軸をスクロールさせるには、どのようにすればいいですか?
Akzeptierte Antwort
MathWorks Support Team
am 29 Jun. 2009
GUI機能を使用して、スライダーバーのコールバック関数に、座標軸の表示範囲を変更するステートメントを記述することで、スクロールさせることができます。以下に例をご紹介します。下記プログラムscrollplotdemoを作成し実行すると、x軸範囲をスクロールするスライダーバーを持ったグラフが表示されます。
【座標軸のx軸をスクロールさせる例】scrollplotdemo.m
function scrollplotdemo
%%%%%プロットするデータの作成
x=0:1e-2:2*pi;
y=sin(x);
dx=2;
% dxは表示するx軸の長さ(ウィンドウの長さ)
a=gca;
p=plot(x,y);
%%%%%描画形式や軸範囲の設定
set(gcf,'doublebuffer','on');
% スクロールする際の画面のちらつきを抑える
set(a,'xlim',[0 dx]);
set(a,'ylim',[min(y) max(y)]);
%%%%%Uicontrol初期化のためのデータを作成
pos=get(a,'position');
Newpos=[pos(1) pos(2)-0.1 pos(3) 0.05];
% スライダーバーの描画位置を設定(座標軸と同じ横幅で
% 座標軸の少し下側に表示)
xmax=max(x);
S=['set(gca,''xlim'',get(gcbo,''value'')+[0 ' num2str(dx) '])'];
% スライダーバー(gcbo)の位置から座標軸(gca)の
% x軸範囲を設定するコールバック文字列を作成
%%%%%上記設定を使ったUicontrolの作成
h=uicontrol('style','slider',...
'units','normalized','position',Newpos,...
'callback',S,'min',0,'max',xmax-dx);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu グラフィックス オブジェクトのプロパティ finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!