MATLAB: How to delete/remove an extra yaxis (inserted by addaxis function), without removing the line that was created with the addaxis function.

delete y-axismultiple y-axis

Hello. Sorry to bother you, but i think i have tried everything by now.. I have the following figure, in which the red and blue y-axis were created with the addaxis function (https://www.mathworks.com/matlabcentral/fileexchange/9016-addaxis). Due to the fact that i have same x- axis -intervals but different y-axis- intervals for the lines ploted (the 2 red lines have the same y intervals, the 2 blue lines have the same, the 2 black have the same) i used the addaxis function in order to be able to create this figure. But there are 2 extra y-axis, the one red and the one blue with no label, that i want gone, but with keeping the corresponding lines to those y-axis. Is there a possible way to do that, or another approach in order to create such a figure? Thank you very much in advance for your time!! Stay safe!!

Best Answer

The two blue and the two red axes have the same scale; there's no point in creating the extra ones; just plot both blue and both red lines when the respective axis is created.
You can do that by using a 2-column Y array for each or by "hold on" before adding the second line for each.
Once you created the axes and added the line; the line is a child of that axes and so if you remove that axes, you remove the line. You could make those two axes invisible so they wouldn't show, of course, but they would still be there and take up room for no purpose.
IOW, instead of removing something, don't create something unwanted/unneeded in the first place.