Plot.i want my Y axis...

5 visualizzazioni (ultimi 30 giorni)
oner
oner il 2 Gen 2013
I plot a graph.its y axis is between -0.5 and 0.5. But i want it between -1 and 1.like this -1 , -0.8 , -0.6 , -0.4 , -0.2 , 0 , 0.2 , 0.4 , 0.6 , 0.8 , 1. Thank you in advance

Risposte (2)

Walter Roberson
Walter Roberson il 2 Gen 2013
ylim([-1 1])

Mark Mikofski
Mark Mikofski il 2 Gen 2013
See help for ylim to set the y-axis limits:
ylim([YMIN, YMAX])
or in your case
ylim([-1, 1])
then to set the tick marks use the set and get methods for the current axis. See help on gca, axes and axes properties:
plot(x,y); % assuming you have some data to plot called X and Y
set(gca, 'YTick', [-1:0.2:1], 'YLim', [-1, 1]) % set the y-axis limits too
gca is a handle to the current axes. You may need to click on the plot in the figure you want to edit.
You can also use MATLAB's gui Plot Tools by clicking on the "Show Plot Tools and Dock Figure" button on the toolbar, usually the last one on the right. You could also access this from the menu bar: Edit > Axes Properties..., which does the same thing. Then select the Y Axis tab and set teh limits and click the Ticks button to set the ticks.
Explore the figure and use the help docs, and you will find many ways to achiev your goal. Good luck!

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by