问题描述
我在一个图中有多个子图.每个图的 X 轴是相同的变量(时间).每个图上的 Y 轴都不同(在它代表的内容和数据的大小方面).
I have multiple subplots in one figure. The X axis of each plot is the same variable (time). The Y axis on each plot is different (both in what it represents and the magnitude of the data).
我想要一种同时放大所有图的时间尺度的方法.理想情况下,通过在其中一个图上使用矩形缩放工具,并让其他图相应地更改其 X 限制.对于所有这些,Y 限制应保持不变.自动拟合数据以在 Y 方向填充图是可以接受的.
I would like a way to zoom in on the time scale on all plots simultaneously. Ideally by using the rectangle zoom tool on one of the plots, and having the other plots change their X limits accordingly. The Y limits should remained unchanged for all of this. Auto fitting the data to fill the plot in the Y direction is acceptable.
(这个问题几乎与 Stack Overflow 问题一相同 Matplotlib/Pyplot:如何将子图一起缩放?(MATLAB 除外)))
(This question is almost identical to Stack Overflow question one Matplotlib/Pyplot: How to zoom subplots together? (except for MATLAB))
推荐答案
使用内置的linkaxes 函数如下:
Use the built-in linkaxes function as follows:
linkaxes([hAxes1,hAxes2,hAxes3], 'x');
对于更高级的链接(不仅仅是 x 或 y 轴),请使用内置的 linkprop 函数
For more advanced linking (not just the x or y axes), use the built-in linkprop function
这篇关于MATLAB - 如何一起缩放子图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!