plot in predesigned figure

3 ビュー (過去 30 日間)
Josefina Ottitsch
Josefina Ottitsch 2019 年 5 月 27 日
回答済み: Jayanti 2024 年 10 月 11 日
Hello everyone!
I want to plot a small function in a predesigned figure. The script is the attachment called hw and my function which creates my predesigned figure is f_vorlage.
Now as you can see, the programm hw creates my desired figure, but then overwrites it with a clear figure and then draws the sin(x) function in the cleared figure.
How can I fix this?
Thank you so much for the support!:)
  1 件のコメント
Star Strider
Star Strider 2019 年 5 月 27 日
I am not certain what you are doing.
See if Position Multiple Axes in Figure does what you want.

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

回答 (1 件)

Jayanti
Jayanti 2024 年 10 月 11 日
Hi Josefina,
I understand that you want to create a plot on top of the predesigned figure created by f_vorlage without overwriting the existing figure.
hold oncan be used to allow new plots to overlay on the current figure without erasing it. Also to ensure that the plot created by “hw is correctly placed on the axes set up by f_vorlage, return the axes handle as below:
ax = f_vorlage(s);
This handle will allow you to interact with the specific axes created or modified by f_vorlage. When plotting data in “hw, you can use this axis handle to specify exactly on which axes the plot should be displayed by passing handle as first argument to plot function.
I am attaching below code for your reference.
hold on;
plot(ax,x, sin(x));
hold off;
I am also attaching official MathWorks documentation of “hold” function for your reference:
Hope it helps.

カテゴリ

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