matlabplotgetpropertyeditor

In a MATLAB plot, how do I query the y-axis limits using the get command?


I do not understand how to use the get command to "query the y-axis limits." I know I can find the property related to the axis limits in the Property Editor, but I cannot find it and I got stuck.


Solution

  • As a generalized version of my comment, you can fetch any property you want with the get command using the exact same name those properties have in the Property Editor/Inspector.

    For instance, in your case the property YLim exists in the Property Inspector under this very name, so in a script/function you can fetch it using:

    get(HandlestoAxis,'YLim')
    

    where the output is a 1x2 vector and HandlestoAxis is the handles to any axis you want. For the current axis you can use gca.