tiledlayout doesn't work with uifigure?

37 visualizzazioni (ultimi 30 giorni)
powl
powl il 29 Apr 2020
Commentato: Paul Hamacher il 30 Apr 2020
Hi, I just encountered a strange behaviour. I recently programmed a script witch uses a tiledlayout within an uifigure. It worked well so far until today, when Matlab refuses to apply the tiledlayout onto the already opened uifigure but instead opens a separate figure.
fig = uifigure;
tiledlayout(1, 2);
nexttile(1)
plot(0)
nexttile(2)
plot(0)
That's a demoscript witch provokes the described behaviour. As soon as tiledlayout gets called a new figure opens and the uifigure is ignored. I wrote my script in Matlab R2019b but also upgraded to a fresh R2020a today. Same behaviour. I can't tell why it worked well so far but suddenly started to behave strangely as of today. Any clues?

Risposte (2)

Ameer Hamza
Ameer Hamza il 29 Apr 2020
Explicitly specify the handles of graphic objects
fig = uifigure;
t = tiledlayout(fig, 1, 2);
ax = nexttile(t);
plot(ax, 0)
ax = nexttile(t);
plot(ax, 0)
  9 Commenti
powl
powl il 30 Apr 2020
Well, I didn't need to use polaraxes in the first place. I Just called polarplot and it worked. Here is the original code that created my window in a simplified form:
fig = uifigure;
ldbtn = uibutton(fig);
ldbtn.Position = [360 30 60 22];
ldbtn.Text = 'Rnd';
svbtn = uibutton(fig);
svbtn.Position = [440 30 60 22];
svbtn.Text = 'Save';
rho = linspace(0, 2*pi, n);
axx = [1 n -0.3 0.3];
tiledlayout(5, 3);
nexttile(1)
p11 = plot(sin1);
p11.YDataSource = 'sin1';
t11 = title('');
axis(axx);
nexttile(4)
p12 = plot(sin2);
p12.YDataSource = 'sin2';
t12 = title('');
axis(axx);
nexttile(7)
p13 = plot(sin3);
p13.YDataSource = 'sin3';
t13 = title('');
axis(axx);
nexttile(10)
p14 = plot(sin4);
p14.YDataSource = 'sin4';
t14 = title('');
axis(axx);
nexttile(13)
p13 = plot(current_flip);
p13.YDataSource = 'current_flip';
title('sum');
axis(axx);
nexttile([5 2])
p2 = polarplot(rho, current);
axis([1 361 -1 1]);
p2.YDataSource = 'current';
After 'the incident' happened, literally every single ui instruction I don't give a reference to the already opened uifigure tries to open its own figure. That wasn't the case before. It used to look like this:
Ameer Hamza
Ameer Hamza il 30 Apr 2020
It is quite strange that you were able to make such a thing in uifigure yesterday. I tried to make polaraxes over the tiledlayout, and it is proving to be quite difficult. The following code shows a workaround. Maybe you can file a bug report (not sure, if it is a bug or intended behavior ?) or at least a feature request to make the process of creating polaraxes over tiledlayout in uifigure a bit easier.
fig = uifigure;
ldbtn = uibutton(fig);
ldbtn.Position = [360 30 60 22];
ldbtn.Text = 'Rnd';
svbtn = uibutton(fig);
svbtn.Position = [440 30 60 22];
svbtn.Text = 'Save';
n=100;
rho = linspace(0, 2*pi, n);
axx = [1 n -0.3 0.3];
t = tiledlayout(fig, 5, 3);
ax = nexttile(t,1);
p11 = plot(ax, 0);
p11.YDataSource = 'sin1';
t11 = title(ax,'');
axis(ax,axx);
ax = nexttile(t,4);
p12 = plot(ax, 0);
p12.YDataSource = 'sin2';
t12 = title(ax,'');
axis(ax,axx);
ax = nexttile(t,7);
p13 = plot(ax, 0);
p13.YDataSource = 'sin3';
t13 = title(ax,'');
axis(ax,axx);
ax = nexttile(t,10);
p14 = plot(ax,0);
p14.YDataSource = 'sin4';
t14 = title(ax,'');
axis(ax,axx);
ax = nexttile(t,13);
p13 = plot(ax,0);
p13.YDataSource = 'current_flip';
title(ax,'sum');
axis(ax,axx);
ax = nexttile(t,[5 2]);
ax.Visible = 'off';
pax = polaraxes(fig);
pax.Position = ax.Position;
p2 = polarplot(pax,1, 1);
axis(ax,[1 361 -1 1]);
p2.YDataSource = 'current';

Accedi per commentare.


Paul Hamacher
Paul Hamacher il 30 Apr 2020
Modificato: Paul Hamacher il 30 Apr 2020
Thank you for you effort! I think the problem arises from the fact, that I try to combine "old" (GUIDE, figure) and "new" (appDesigner, uifigure) GUI elements together in the first place. I think tiledlayout isn't inteded to work with uifigure. I can't tell why it worked at first and then suddenly stopped working. ?
I will try to re-implement my GUI with only new GUI elements (uigridlayout instead of tiledlayout...). Maybe this is easier. This was the first time I worked with gui elements. Compared to other programming environments, GUI programming seems a bit hard to me in Matlab.
  2 Commenti
Ameer Hamza
Ameer Hamza il 30 Apr 2020
Yes, making older graphical elements to work with the uifigure can be a bit of pain. You can try to use uigridlayout since it was specifically made for uifigure. The only thing I find confusing is why it was working before since you didn't even update MATLAB, so there shouldn't be any major changes. I don't think there is a physical explanation for this. Something supernatural must be going on with your system :D
Paul Hamacher
Paul Hamacher il 30 Apr 2020
I couldn't give a better explanation for this behaviour! ?

Accedi per commentare.

Categorie

Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by