I'm trying to break yaxis multiple times by using breakyaxis. As seen in the comments of the link, other people also seem to have the issue of breaking the y-axis multiple times. For example:
x = linspace(0,10,11);
y1 = 0.01*x;
y2 = -0.01*x + 5;
y3 = 0.05*x + 10;
plot(x,y1)
hold on
plot(x,y2)
plot(x,y3)
hold off
Note that because the slope is so small relative the the constant in the equation, plotting the graphs together will result in 3 flat looking lines. I want to show the slope by breaking yaxis twice in between y1 and y2, and y2 and y3. However if I try:
x = linspace(0,10,11);
y1 = 0.01*x;
y2 = -0.01*x + 5;
y3 = 0.05*x + 10;
plot(x,y1)
hold on
plot(x,y2)
plot(x,y3)
breakyaxis([0.15 4.85])
breakyaxis([5.05 9.95])
hold off
I get an error message saying: "splitYLim must be in the range given by get(AX,'YLim')".
Using just 1 breakyaxis function works perfectly. Is there a way that I can break my yaxis twice?
Note: This is just a made-up data to explain my problem, and I have to plot them all in 1 graph, so splitting the graph is not the solution. I don't mind using other functions, as long as I can break my yaxis twice.
EDIT:
I did a little more of debugging, and the error message is coming from line 72-75 in breakyaxis. Here is the codes that triggers the error message:
mainYLim = get(mainAxes,'YLim');
if (any(splitYLim >= mainYLim(2)) || any(splitYLim <= mainYLim(1)))
error('splitYLim must be in the range given by get(AX,''YLim'')');
end
In the first breakyaxis, mainYLim is set to [0,12], and splitYLim is set to the range that I specify: [0.15, 4.85].
However, in the second breakyaxis, mainYLim is set to [0,1], and splitYLim ([5.05, 9.95]) is outside the range of mainYLim.
Note that mainAxes is defined earlier in the code as mainAxes = gca
.
The problem, thus, is due to the fact that in second breakyaxis, mainYLim is reporting a range much smaller than what my plot needs. How can I fix it?