How to plot just a colorbar without plot?
조회 수: 105 (최근 30일)
이전 댓글 표시
I would like to plot just a colorbar on a subplot without real figure. I can do this, but I want to shrink the figure area. How to make zero figure width and wide colorbar?
댓글 수: 4
답변 (1개)
Benjamin Kraus
2018년 7월 26일
A colorbar must be attached to an axes, so you have (at least) two options:
- Create an axes, attach a colorbar, then make the axes invisible.
- Create an axes, attach a colorbar, then move the axes and colorbar separately.
For example:
ax = axes;
c = colorbar(ax);
ax.Visible = 'off';
댓글 수: 3
Benjamin Kraus
2018년 12월 17일
The Visible property on axes controls the visibility of the axes (the backdrop, the rulers, the ticks, etc.) but does not control the visibility of the plots within the axes (lines, bar graphics, etc.). Is this the issue you are seeing? If not, please post some example code along with a screenshot of what you are seeing, and someone should be able to help you.
Turlough Hughes
2022년 1월 4일
One can also center the colorbar in the figure as follows:
hf = figure('Units','normalized');
colormap turbo
hCB = colorbar('north');
set(gca,'Visible',false)
hCB.Position = [0.15 0.3 0.74 0.4];
hf.Position(4) = 0.1000;
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!