Error in nexttile after adding colorbar for whole tiledlayout

2 次查看(过去 30 天)
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?

回答(1 个)

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.

类别

Help CenterFile Exchange 中查找有关 Graphics 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by