How to save changes to XLim so they are maintained when the user hits 'Restore View'/Home button
25 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have a figure that was generated by a different function, and I am overlaying additional data on top of it. Because of the new data I have added, I need to change the XLim properties in permanent, non-volatile way.
I have changed the setting on Property Inspector and saved the figure, but if I hit the "Restore View" button (which uses a home as its icon), it resets the XLim back to the values from when the figure was initially created.
I cannot recreate the figure from scratch, as I do not have all the source data, so is there a way to permanently modify a figure's default view options?
0 件のコメント
回答 (2 件)
Mario Malic
2025 年 11 月 20 日 21:22
Hello there,
It's been a while since I have seen a figure window, but can you make your x-axis limits to be manual?
xlim("manual")
After you add new data, pressing home should not change the limits.
Hope it helps.
dpb
2025 年 11 月 23 日 17:43
編集済み: dpb
2025 年 11 月 24 日 16:56
Try
newXlim=[x1 x2]; % the new limits desired
hAx=gca;
hAx.Xlim=newXLim; % set the observed limits
hAx.InteractionOptions.RestoredXLimits=hAx.XLim; % and then the restored valuees to match new
If using the interactive stuff (I never do), the interactive options may not be visible as they're supposed to be what the Home button reverts to so Mathworks probably figures they shouldn't be changed in order to be able to "unzoom", etc.
See if can set to the value you want to maintain after setting the new limits will break the old behavior. Note the above property doesn't exist until R2022b and later; before it is totally internal, not just a hidden/undocumented property.
At the moment I'm involved with a packaged app that was built with R2021b on a locked-down-by-IT system for the local community college so isn't convenient to try to test locally...
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
