Object orientated approach for creating plots with three or more y axis. myaxisc, short for "Multiple Y Axis Class", is a class holding all the axes objects needed to display multiple Y axis. Second axis is placed on the right side, the additional axes are placed on the left side.
- Creates axes with as much additional Y axis as you want (as long as there is enough space, minimum are 2 y axis).
- Works with MATLAB App Designer as well as in regular Matlab Figures and therefore also in programmatic created GUIs.
- Full working zoom and pan functionality in App Designer UIFigures (extra buttons required) and in regular Figures using axtoolbar.
- When zoom or pan is not active, single y-axis can be panned.
- Includes some easy to use basic methods to modify appearance: Labels, Limits, Colors, FontSize, Position
Two example files (myaxisc_example.m and myaxisc_app.mlapp) are included to demonstrate usage.
Usage in regular Figures: Create myaxisc-object "h" and call plot with specified axes to plot into:
h = myaxisc(4,0.1); % Create myaxisc-object "h" with 4 y axes and a spacing of 0.1
plot(h.p(3),x,y) % Create plot in third axes using method "p"
Usage in App Designer: Its recommended to create a container panel to put the axes into. Use startupFcn to then create the axes into the container panel. See the attached example file for details. You need to add some functions and properties and also implement the buttons by yourself.
Installation: Nothing special, just make sure the myaxisc.m-File is in path.
There is a lot of compatibility coded into the class so it should behave the same way in App Designer UIFigures as well as in regular Figures and programmatic created Apps. Even though zooming and panning methods are implemented completely different, they should behave the same way. Unfortunately it is still possible to drag single line objects sometimes in uifigure so panning may behave buggy.
vik (2021). myaxisc (https://www.mathworks.com/matlabcentral/fileexchange/70033-myaxisc), MATLAB Central File Exchange. Retrieved .
how can I change the ubication of the y, I mean I'd like to have 4 y axis, but two on the right side and two on the left side
Regarding questions about changing ytickformat or using reverse y-axis: You can access the used axes-objects with the functions "p(n)" and "l(n)" with n beeing the y axes number and use the set command on it like on normal y axes. "p" will return a handle to the axes object used to plot the line and "l" will return the axes object which is used to display the axes itself. So for example, to change the property ytickformat, use .l in set command, like "set(h.l(3),'ytickformat', ...".
A lot easier to use than addaxis. Is there a way to change the ytickformat?
Helped a lot and very intuitive to use when you look at the example. Worked really well for me
I like it a lot more than addaxis. I was just wondering if there is a possibility to use a reversed y-axis? It doesn't seem to accept 'Ydir'.
Is there any way to use this function in subplot? The additional axis don't scale according to subplot.
very useful script and documentation very clear
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!