How to plot() with axes through the origin?

31 ビュー (過去 30 日間)
robert bristow-johnson
robert bristow-johnson 2016 年 12 月 14 日
回答済み: SenorPorky 2017 年 9 月 20 日
I have found these two references:
First reference: https://www.mathworks.com/help/matlab/creating_plots/display-axis-lines-through-origin.html
This has the error:
While setting the 'XAxisLocation' property of Axes: 'origin' is not a valid value. Use one of these values: 'bottom' | 'top'. Error in plotafunction (line 39) ax.XAxisLocation = 'origin';
and there exists no function titled: PlotAxisAtOrigin(x,y).
Can someone tell me simply how to plot a simple mathematical graph with the axes through the origin like that taught us in school?
MATLAB R2015a
thanks. r b-j

回答 (3 件)

Steven Lord
Steven Lord 2016 年 12 月 14 日
The ability to specify the 'origin' value for the XAxisLocation and YAxisLocation properties of an axes was introduced in release R2015b.

KSSV
KSSV 2016 年 12 月 14 日
Go to this link: http://in.mathworks.com/matlabcentral/fileexchange/10473-plotaxisatorigin and download the function PlotAxisAtOrigin. Read the documentation part in the code. It works fine.

SenorPorky
SenorPorky 2017 年 9 月 20 日
Sup
Here is the code you need. Adjust your range as needed.
hold on
grid on
x=linspace(-150,150) ;
y=linspace(0,0) ;
plot(x,y,'k-') ;
plot(y,x,'k-') ;
Cheers!

カテゴリ

Help Center および File ExchangeGraphics についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by