Fixing InnerPosition for UIAxes with no ActivePositionProperty

15 Ansichten (letzte 30 Tage)
Matt_Z
Matt_Z am 14 Jan. 2019
Beantwortet: vik am 7 Feb. 2019
Hi,
created a App Designer UIfigure which automatically splits the UIAxes for timeseries data depending on the type of information shown (scalar, vector, direction etc). As it is timseries data i'd like the UIAxes inner position (i.e. the old Axes 'position' property, excluding labels and margins) to have identical x limits across the UIFigure.
As UIAxes has no ActivePositionProperty, and position is no longer specified according to InnerPosition (Position is now OuterPosition in UIAxes) there seems to not be a straightforward way of achieving this.
Any guidance from those that have faced this would be most helpful.
Thanks,
Matt

Antworten (1)

vik
vik am 7 Feb. 2019
I guess UIAxes is just a container containing regular Axes class (if you access protected properties by assigning a uiaxes handle to a struct, you can see the regular Axes). Therefore, UIFigures still supports using regular Axes Class, you just have to program them manually.
I highly recommend adding the axes into a panel-container, then you can position them with 0...1-Values and resizing the whole window works nice. If you add axes to uifigure-window, the resizing is a mess and I guess that is one of the reasons UIAxes was made.
You cannot add your own code to the grey areas, but you can add most of the things you need at the ribbon toolbar at "insert".
1) Add a Panel to the GUI
2) Add a public property
properties (Access = public)
h_ax matlab.graphics.axis.Axes
end
3) Add a a "startupFcn"-Callback to the UIFigure Window to call a user defined function
% Code that executes after component creation
function startupFcn(app)
app.funcAddProgComponents;
end
4) Add a private user defined function which is called above and use it to create regular axes
methods (Access = private)
function funcAddProgComponents(app)
% Create classic Axes object into the Panel
app.h_ax = axes(app.Panel,'Position',[0.1,0.1,0.8,0.8]);
% Set some properties:
app.h_ax.XLim = [0,1];
end
end
5) Plot into this axes using
plot(app.h_ax,x,y,,...
All Positioning, setting limits and so on can be done by setting all the known properties of the axes class.
App Designer will show a warning here but so far it worked for me. See attached example.

Kategorien

Mehr zu Develop uifigure-Based Apps finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by