Zooming separately on both data sets while using plotyy
古いコメントを表示
Is there anyway that I can selectively zoom on the two data sets when I am using plotyy?
In other words I want to re-scale and position the the data separately after plotting and can't seem to make this happen as of now. I came across the following but, I wasn't sure how I could convert it into a function for automatic plotting using plotyy:
2 件のコメント
dpb
2013 年 9 月 13 日
You've already got two independent axes w/ plotyy -- the only real piece it would seem you'd need to add would be to hide the non-selected of the two axes when selected the other -- as is by default they both are visible and simply overlay so it visually looks as though there's only one.
Donald John
2013 年 9 月 16 日
採用された回答
その他の回答 (1 件)
Sean de Wolski
2013 年 9 月 16 日
編集済み: Sean de Wolski
2013 年 9 月 16 日
You can use the function setAllowedAxesZoom to set false for the axes you don't want zooming. Now, why doesn't this work out of the box? When you call plotyy a bunch of hidden listeners are set up to keep the axes aligned, i.e. when one zooms, the other does too.
These listeners are not initiated when generating code for the figure and then setting axes zoom allowed to false. Here's an example with code and instructions:
hFig = figure;
plotyy(1:10,4:13,2:11,1:10:100);
- Now click File Menu -> Generate Code
- Save the file as createfigure.m
The signature should look like this:
createfigure(X1, Y1, X2, Y2);
Change the signature to the following
ax = createfigure(X1, Y1, X2, Y2);
And change the last line of the function to
ax = [axes1 axes2];
Now you are passing back the handles to the axes. Get the zoom handle for the figure and turn it off for the second axes. Here's the full example:
hFig = figure;
ax = createfigure(1:10,4:13,2:11,1:10:100);
h = zoom(hFig);
setAllowAxesZoom(h,ax(2),false);
Enjoy zooming!
4 件のコメント
Donald John
2013 年 9 月 16 日
Sean de Wolski
2013 年 9 月 16 日
Well you copy the contents out of the function that is autogenerated (this will look similar to Jan's code below) and then use that inlined in your script. That is your call, I would keep the createfigure function as its own, that way it can be used again in another script if necessary.
Donald John
2013 年 9 月 16 日
Sean de Wolski
2013 年 9 月 16 日
Look in the figure file menu at the top left corner of the figure.
カテゴリ
ヘルプ センター および File Exchange で Two y-axis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!