In MATLAB, when we create a plot using the plot
function, we can specify the y-axis limits and the position of the y-tick labels using the ytick
property.
The ytick
property accepts an array that specifies the y-tick values. For example, the following code sets the y-tick values to be -1, 0, 1, and 2:
main.m113 chars8 lines
This code will create a sine wave and set the y-tick labels to be -1, 0, 1, and 2.
Alternatively, you can also set the y-tick values and labels using the yticklabels
property. The following code sets the y-tick values to be -1, 0, 1, and 2, and the y-tick labels to be 'neg', 'zero', 'pos', and 'two':
main.m157 chars9 lines
This code will create a sine wave and set the y-tick labels to be 'neg', 'zero', 'pos', and 'two'.
gistlibby LogSnag