app designer - how to add multiple x-axes on top and bottom of uiaxes

28 ビュー (過去 30 日間)
Sveta Golod
Sveta Golod 2020 年 5 月 18 日
回答済み: Ali BOULGSOA 2022 年 11 月 15 日
I want to display a plot in appdesigner with multiple x-axes and y axes.
I have a GUI with axes object. I succeeded to add second Y axis by using:
yyaxis(app.UIAxes,'right')
plot(app.UIAxes,.....)
But I can't figure out how to add second x axes.
by using:
ax2 = axes('Position',app.UIAxes.Position,'XAxisLocation','top','YAxisLocation','right','Color','none');
plot(ax2,Iout,yout,'o-r','Parent',ax2)
But it doesn't work, it creates a new figure outside the GUI instead.
  2 件のコメント
Anna Sergeeva
Anna Sergeeva 2021 年 3 月 17 日
編集済み: Anna Sergeeva 2021 年 3 月 17 日
Hi
Did you solve your problem?
I am sitting with a similar problem now. I want to plot 16 curves in the same app.UIAxes but with different y-axes.
If I do as described in the accepted answer, I get an error
function startupFcn(app)
app.ax1 = axes(app.UIFigure)
app.ax2 = axes(app.UIFigure)
% Do additional processing to add plots to the axes, change positioning, etc.
end
Best
Anna
Sveta Golod
Sveta Golod 2021 年 3 月 24 日
Finally in my application I used just one x-axes, and it was good enough for me.
So I don't have a code to share... sorry

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

採用された回答

Sveta Golod
Sveta Golod 2020 年 7 月 19 日
I got an MathWorks response:
From what I understand, you would like to display multiple x-axes in a "uifigure" component created in App Designer. Please let me know if my understanding is incorrect.
Unfortunately, this is not possible with the "uiaxes" component.
However, one possible workaround for this issue is to use regular axes objects in an App Designer application instead of using the default UIAxes objects. The regular axes objects cannot be added to the App Designer application with the drag and drop interface in the "Design View", but they can be added to a UIFigure programatically.
To achieve this workflow, a startup function for the UIFigure could be added to the App Designer application. Within this startup function, two new axes objects could be created, with the parent of the axes set to be the UIFigure. I have included a snippet of code to demonstrate this workflow within the startup function.
function startupFcn(app)
app.ax1 = axes(app.UIFigure)
app.ax2 = axes(app.UIFigure)
% Do additional processing to add plots to the axes, change positioning, etc.
end
Once these axes objects are created, you can perform the necessary manipulations of setting the positions, adjusting the axes locations, changing the background colors, etc.
  2 件のコメント
Gina Abdelhalim
Gina Abdelhalim 2020 年 10 月 7 日
could you maybe post what your code looks like? I am trying to do it, but i keep getting errors! i would appreciate your help very much
jonas
jonas 2020 年 10 月 12 日
I guess ax1 and ax2 are global properties, so if you want to save the handles in app.x then you need to define them first
properties (Access = public)
ax1
ax2
end

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

その他の回答 (2 件)

Shubh Sahu
Shubh Sahu 2020 年 6 月 23 日
  1 件のコメント
Sveta Golod
Sveta Golod 2020 年 7 月 6 日
編集済み: Sveta Golod 2020 年 7 月 6 日
no, it doesn't help in GUI with UIAxes....

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


Ali BOULGSOA
Ali BOULGSOA 2022 年 11 月 15 日
I have found the answer to your question :
hold(app.UIAxes,'on')
Unable to resolve the name 'app.UIAxes'.
yyaxis(app.UIAxes,'left')
loglog(app.UIAxes,Ti,xt)
app.UIAxes.YLimMode = 'auto';
app.UIAxes.XLimMode = 'auto';
app.UIAxes.XScale='log';
colorbar(app.UIAxes,'off');
app.UIAxes.XLabel.String ='Time (s)'
app.UIAxes.YLabel.String = 'Amplitude (%)';
yyaxis(app.UIAxes,'right')
loglog(app.UIAxes,Ti,population)
app.UIAxes.YLimMode = 'auto';
app.UIAxes.XLimMode = 'auto';
colorbar(app.UIAxes,'off');
app.UIAxes.XLabel.String = 'Time (s)';
app.UIAxes.YLabel.String = 'Population (%)';
hold(app.UIAxes,'off')

カテゴリ

Help Center および File ExchangeDevelop uifigure-Based Apps についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by