I have a figure containing two subplots. Their axes are stored as follows:
我有一个包含两个子图的图。它们的轴存储如下:
for i = 1:n
ax(i) = subplot(n,1,i);
end
after plotting, I have attempted to link the axes together. When I do:
在绘图之后,我试图将轴连接在一起。当我做:
yyaxis right; linkaxes(ax);
yyaxis left; linkaxes(ax);
I get the right side axes matching, but then the left side of the first figure links to the same scale as the two right side axes, rather than the other left side axis.
我得到右侧轴匹配,但是第一个图的左侧链接到与两个右侧轴相同的比例,而不是另一个左侧轴。
I have also tried:
我也尝试过:
yyaxis right; linkprop(ax, 'Ylim')
yyaxis left; linkprop(ax, 'Ylim')
which results in the same problem. I'm trying to find a simple way to have the left y axes link together and the right y axes link together, but remain independent from their opposite axis sides. Any help would be marvelous.
这导致了同样的问题。我试图找到一种简单的方法让左侧的y轴连接在一起,右侧的y轴连接在一起,但保持独立于它们的相对轴侧。任何帮助都会很棒。
1 个解决方案
#1
1
"linkprop" saves the properties over multiple call (as long as you define the variable "link1, link2..."). For example, I linked the Y axis of the top row, and the Y axis of the bottom row independently. With the third call, I was able to link all the X axis together, keeping the independent link between the Y axis.
“linkprop”将属性保存在多个调用上(只要您定义变量“link1,link2 ...”)。例如,我独立地链接了顶行的Y轴和底行的Y轴。通过第三次调用,我能够将所有X轴连接在一起,保持Y轴之间的独立链接。
Just make sure to save each linkprop call to a different variable
只需确保将每个linkprop调用保存到另一个变量
ax{1,1} = subplot(2,2,1);
ax{1,2} = subplot(2,2,2);
ax{2,1} = subplot(2,2,3);
ax{2,2} = subplot(2,2,4);
link1 = linkprop([ax{1,1},ax{1,2}], 'YLim');
link2 = linkprop([ax{2,1},ax{2,2}], 'YLim');
link3 = linkprop([ax{1,1},ax{1,2},ax{2,1},ax{2,2}],'XLim');
#1
1
"linkprop" saves the properties over multiple call (as long as you define the variable "link1, link2..."). For example, I linked the Y axis of the top row, and the Y axis of the bottom row independently. With the third call, I was able to link all the X axis together, keeping the independent link between the Y axis.
“linkprop”将属性保存在多个调用上(只要您定义变量“link1,link2 ...”)。例如,我独立地链接了顶行的Y轴和底行的Y轴。通过第三次调用,我能够将所有X轴连接在一起,保持Y轴之间的独立链接。
Just make sure to save each linkprop call to a different variable
只需确保将每个linkprop调用保存到另一个变量
ax{1,1} = subplot(2,2,1);
ax{1,2} = subplot(2,2,2);
ax{2,1} = subplot(2,2,3);
ax{2,2} = subplot(2,2,4);
link1 = linkprop([ax{1,1},ax{1,2}], 'YLim');
link2 = linkprop([ax{2,1},ax{2,2}], 'YLim');
link3 = linkprop([ax{1,1},ax{1,2},ax{2,1},ax{2,2}],'XLim');