Error in nexttile after adding colorbar for whole tiledlayout

조회 수: 6 (최근 30일)
Linus
Linus 2020년 11월 21일
답변: Srivardhan Gadila 2020년 11월 28일
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에서 Colorbar에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by