Setting axes with center in origin (0,0) in plotted variables.

1,075 ビュー (過去 30 日間)
Kasper
Kasper 2011 年 5 月 12 日
コメント済み: Jan Kappen 2022 年 5 月 3 日
Hey community, I have two variables with x 1 double data. I am to plot these two in a plot, but would like to have the axes to be intersecting each other in origin (0,0). Instead in the axes are shown with intersecting at for example (-2000,-6), my lowest x-value is -1200, lowest y-value is -6. Here it would be great to have the x-axis through y=0, so that differences from y=0 easily can be seen graphically.
How would I do that, is there a command you could use in the script written, to make it move the axes? I have a large script to evaluate a lot of graphs in, so a MATLAB-command would be preferable to a tool in the figure builder.
The (simple) code used is as following:
%%person5 - Puls
hold on
plot(person5_ethanol_ekgpuls_tid,person5_ethanol_ekgpuls,'g.-')
xlabel('Tid/Sek')
ylabel('Blodtryk/MmHg')
title('Forsøgsperson #5 Ethanol Ekg Puls')
Hope that my question is understandable and that it can be done.

採用された回答

Walter Roberson
Walter Roberson 2011 年 5 月 12 日
  2 件のコメント
Kasper
Kasper 2011 年 5 月 14 日
Great, just what I needed, especially the sidenote on the commands hline and vline was useful for me. Thanks
Maty
Maty 2014 年 4 月 27 日
Great!!!

サインインしてコメントする。

その他の回答 (3 件)

Rini Varghese
Rini Varghese 2018 年 3 月 1 日
I am sure you are aware of the most straightforward solution to this is now available directly through MATLAB's axes option:
ax = gca;
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
  1 件のコメント
Jason Duvall
Jason Duvall 2020 年 10 月 18 日
Why are you sure the OP was aware of this? If that was the case, the question probably would not have been posted.

サインインしてコメントする。


Arnaud Miege
Arnaud Miege 2011 年 5 月 12 日
Does the axis command do the trick?
Arnaud
  2 件のコメント
MOHAMMED ALBAYATI
MOHAMMED ALBAYATI 2020 年 4 月 17 日
yes. perfect!
Muhammad Asif
Muhammad Asif 2020 年 8 月 12 日
The simplest soution to this problem is
set(gca, 'XAxisLocation', 'origin', 'YAxisLocation', 'origin')

サインインしてコメントする。


Muhammad Asif
Muhammad Asif 2020 年 8 月 12 日
set(gca, 'XAxisLocation', 'origin', 'YAxisLocation', 'origin')
  1 件のコメント
Jan Kappen
Jan Kappen 2022 年 5 月 3 日
Does not work for 3d plots unfortunately :(

サインインしてコメントする。

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by