Error in nexttile after adding colorbar for whole tiledlayout

조회 수: 16(최근 30일)
Linus
Linus 2020년 11월 21일
답변: VBBV 2021년 10월 14일
I'm encountering this error on Matlab R2020b:
f = figure;
t = tiledlayout(f, 'flow');
nexttile %adding any two plots
plot(1:100)
nexttile
plot(1:100)
cb = colorbar; %adding colorbar
cb.Layout.Tile = 'East' %following the documentation on how to add colorbar for entire tiledlayout
So far, everthing works great. The colorbar belongs to the second axes but it is on the right side of the entire tiledlayout and it looks how it is supposed to. But when I now try to alter the first axes with
nexttile(1)
I get this error message
"Operands to the || and && operators must be convertible to logical scalar values.
Error in nexttile"
Does anyone have a clue what's going on there?

답변(2개)

Srivardhan Gadila
Srivardhan Gadila 2020년 11월 28일
You can try storing the axes when you create a new tile and use the stored axes later as follows:
f = figure;
t = tiledlayout(f, 'flow');
ax1 = nexttile %adding any two plots
plot(1:50)
ax2 = nexttile
plot(1:100)
cb = colorbar;
cb.Layout.Tile = 'East';
% you can make use of the stored axes ax1 and ax2
For more information you can refer to the Examples of the nexttile.

VBBV
VBBV 2021년 10월 14일
f = figure;
t = tiledlayout(f, 'flow');
nexttile %adding any two plots
plot(1:100)
nexttile
plot(1:100)
cb = colorbar; %adding colorbar
cb.Layout.Tile = 'East' %following the documentation on how to add colorbar for entire tiledlayout
cb =
ColorBar with properties: Location: 'layout' Limits: [0 1] FontSize: 8.1000 Position: [0.9160 0.1100 0.0286 0.8150] Units: 'normalized' Show all properties
nexttile(1)
plot(1:100,'o')

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by