How to create a plot with customized axis location?

87 ビュー (過去 30 日間)
Isaac Newton
Isaac Newton 2023 年 4 月 1 日
回答済み: Simon Chan 2023 年 4 月 1 日
Hello everyone
I am writing to ask for your help with creating a MATLAB plot with customized axis location. By default the axis location of x and y are placed in bottom and left of the plot box respectively. However I am wondering if there is a way to adjust the axis location to my desired location.
To provide an example I would like to create a plot similar to the one shown in following attached picture (which I took from a book). As you can see, the x axis with its 'tickslabels' is placed in the middle of the box:
However what one usually gets is different from that as shown in following picture [which x axis is placed in the bottom]:
Thank you in advance.
  2 件のコメント
Isaac Newton
Isaac Newton 2023 年 4 月 1 日
Thank you very much. Actually not the page itself but a link provideed in its comments by Carlos Melo included my answer. Here is the link:
thanks

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

回答 (1 件)

Simon Chan
Simon Chan 2023 年 4 月 1 日
You may move the axis to the origin by setting 'XAxisLocation', or 'YAxisLocation' property to 'origin'.
f = figure;
ax = gca;
plot(ax,-10:1:10,-10:1:10);
set(ax,'XAxisLocation','origin');

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by