How to plot just a colorbar without plot?

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 件のコメント

jonas
jonas 2018 年 7 月 23 日
編集済み: jonas 2018 年 7 月 23 日
It is unclear what you mean. You want the axes area to match the area of the colorbar? Something like the attached image?
Adam
Adam 2018 年 7 月 23 日
Also please make sure of your terminology. The figure is the containing UI for all the elements in it. Is this what you mean or do you mean the axes when you say 'figure area'? Because a zero figure width doesn't make any sense if you really mean 'figure'
Mr M.
Mr M. 2018 年 7 月 26 日
I want a colorbar without graph/plot, and not on the side.
jonas
jonas 2018 年 7 月 26 日
Can you draw an image in MSpaint of what you want?

サインインしてコメントする。

回答 (1 件)

Benjamin Kraus
Benjamin Kraus 2018 年 7 月 26 日

3 投票

A colorbar must be attached to an axes, so you have (at least) two options:
  1. Create an axes, attach a colorbar, then make the axes invisible.
  2. Create an axes, attach a colorbar, then move the axes and colorbar separately.
For example:
ax = axes;
c = colorbar(ax);
ax.Visible = 'off';

3 件のコメント

FTil
FTil 2018 年 12 月 15 日
This did not work for me on R2018a. In spite of setting the Visible property to 'off', the axes remain visible.
Benjamin Kraus
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
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;

サインインしてコメントする。

カテゴリ

タグ

質問済み:

2018 年 7 月 23 日

コメント済み:

2022 年 1 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by