Plot.i want my Y axis...

1 回表示 (過去 30 日間)
oner
oner 2013 年 1 月 2 日
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

回答 (2 件)

Walter Roberson
Walter Roberson 2013 年 1 月 2 日

Mark Mikofski
Mark Mikofski 2013 年 1 月 2 日
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!

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by