How to plot colorbar and plot size different?

조회 수: 5 (최근 30일)
Nisar Ahmed
Nisar Ahmed 2022년 9월 12일
댓글: Star Strider 2022년 9월 15일
Hi
When I plot colorbar, it reduces the size of my actual plot. I have 5 subplot and each has a separate colorbar. How to fix this issue?
I want to plot colorbar for each subplot and next to subplot. how can i solve it?
how can I adjust the ticks on colorbar (interval between colorbar ticks)?

채택된 답변

Star Strider
Star Strider 2022년 9월 12일
One option would be to stretch the figure by adjusting the 'Position' property. It is possible to re-position it and stretch (or compress) it vertically as well, depending on what you want as the result. See the documentation on the Position property for a full description and details.
Example —
x = 0:999;
y = (1:5:25).'+sin((1:5:25).'*2*pi*x/20);
figure
for k = 1:5
subplot(1,5,k)
plot(x, y(k,:))
xlim([0 20])
colorbar
end
sgtitle('Original')
figure
for k = 1:5
subplot(1,5,k)
plot(x, y(k,:))
xlim([0 20])
colorbar
end
pos = get(gcf, 'Position');
set(gcf,'Position',pos+[-50 0 250 0]) % Shift Slightly Left & Stretch To Right
sgtitle('Stretched Width')
.
  댓글 수: 8
Nisar Ahmed
Nisar Ahmed 2022년 9월 15일
@Star Strider Thanks dear
Star Strider
Star Strider 2022년 9월 15일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Purple에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by