I want to limit the figure to positive values so Ylim starts from 0. Here we discuss the introduction, syntax, and steps with output with examples for better understanding. Hello everyone I want to plot a curve with positive and negative values on the Y-axis.
If there is no handle, then the ‘gca’ method will generate one. Subsequent graphics commands target the left side. In MATLAB, gca method is used to get the handle for our current axis. From the documentation: yyaxis left activates the side of the current axes associated with the left y-axis. The steps to be followed for this example are:Īs we can see in the OUTPUT, we have obtained the current axes of the logarithm function defined by us. We will plot a logarithmic function for this example.
YLIM MATLAB CODE
This is my code for creating figures: for k1:30. Figure properties only lets me change ax (1) properties but not ax (2) so I tried setting properties via command line but to no success. After creating the figures, I want to change the y-limits of some of the figures manually. In this example, we will use gca method to get the current axes of our figure. I am creating multiple figures using plotyy inside a loop. This is how our input and output will look like in Matlab command window:Īs we can see in the OUTPUT, we have obtained the current axes of the cos wave defined by us. By default, Matlab extends the axis to the next whole number past the last data point. The plot axis starts at 0 and goes 7 rather than 2pi. Notice that the plot is now a bit asymmetrical. Your plot should look like the following. The steps to be followed for this example are: Try commenting out the xlim and ylim statements and see what happens. We will plot a cos wave for this example. In this example, we will use gca method to get the current axes of our figure. Set the current axes’ limit for the current axesĪs we can see in the OUTPUT, we have obtained the current axes of the sine wave defined by us.Use the plot method to display the figure.Initialize the function whose current axes is required.The steps to be followed for this example are: We will plot a sine wave for this example.
Getting the current axes of the above figureĪs we can see in the OUTPUT, we have obtained the current axes of the exponential function defined by us. This is how our input and output will look like in MATLAB command window: