how to xlimit for 3 different plot in 1 figure?

5 ビュー (過去 30 日間)
arian hoseini
arian hoseini 2024 年 1 月 31 日
コメント済み: Star Strider 2024 年 2 月 4 日
I need to set xlimit for 3 different plot that there are in 1 figure....i set xlimit but it will set for all

採用された回答

Star Strider
Star Strider 2024 年 1 月 31 日
編集済み: Star Strider 2024 年 1 月 31 日
The plots seem not to have been posted, so I am not certain what you want to do.
You would need to set xlim for each one individually, assuming they are each set in separate axes.
Otherwise, you would need to plot each y-vector with a separate x-vector of the same size, although with different start and end values.
  8 件のコメント
arian hoseini
arian hoseini 2024 年 2 月 4 日
Sorry for mis understanding and million Thx to u sir
Star Strider
Star Strider 2024 年 2 月 4 日
As always, my pleasure!
No worries!

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

その他の回答 (2 件)

Benjamin Kraus
Benjamin Kraus 2024 年 1 月 31 日
In your comment you said "I have figure file not the data."
So, starting with a FIG-file, you first need to find the axes within the FIG file:
f = openfig(filename); % Where filename is the path to the FIG file.
ax = findobj(f,'Type','Axes');
Once you've found the axes, if you need to set them all to use the same limits, you can do that in one command:
xlim(ax, [0 9]) % Where [0 9] are the new limits.
If you need to set the limits on each axes different, it is a bit more complicated, because you need to identify which axes is which. There are several ways to do that. If they have titles, you are in luck, because you can just display the axes handles at the command line to see the titles for each axes. If you just run "ax" (the name of the variable) on the command line, you will get a list of all the axes with their titles.
ax
Once you've done that, you can pick which one you want to have each limits and set them.
xlim(ax(1), [0 9]);
xlim(ax(2), [2 10]);
% etc.
If you don't have titles on the axes, you need to determine which axes handle corresponds to which axes. There are a few options, but they all boil down to looking for (or adding) some distinguishing characteristic.
  1. Set the Color of each axes, temporarily, to some distinguishing color, so you can see which one you have a handle to, then set it back to the original color (defaults to white).
  2. Check the existing XLim or YLim (if they are different on different axes).
  3. Add titles to each axes, then use the above technique.
  4. Set the Visible property on one axes to 'off', see which one disappears, then set Visible back to 'on'.
  5. Or just pick one, set the XLim, if you picked the wrong one, you will see which one changed, and can set it to the correct value.
  1 件のコメント
arian hoseini
arian hoseini 2024 年 2 月 1 日
i wanna add 'a' ito that figure and 'It' should e 28 to 328 and 'a' should be 0 to 601....the prolem is first one has 300 value and secod one has 601...is that even possible?can i do that?

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


Austin M. Weber
Austin M. Weber 2024 年 1 月 31 日
% Example plot
subplot(3,1,1)
plot(rand(10,10))
subplot(3,1,2)
plot(rand(10,10))
subplot(3,1,3)
plot(rand(10,10))
% Set the xlimits to be 0 to 9 for each plot
ax = findobj(gcf,'Type','Axes');
for i = 1:length(ax)
ax(i).XLim = [0,9];
end
  1 件のコメント
Benjamin Kraus
Benjamin Kraus 2024 年 1 月 31 日
You don't need the for loop:
ax = findobj(gcf,'Type','Axes');
xlim(ax, [0 9]);

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

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by