How to add a colormap manually as x-axis under an histogram?

7 ビュー (過去 30 日間)
Olfa Lopez
Olfa Lopez 2020 年 3 月 18 日
コメント済み: Roger Breton 2022 年 1 月 16 日
Dear all,
I have created an histogram to look at the distribution of pixels per grey in an (8-bit) image. The reason for not using the imhist function is because I create an histogram with a double y-axis, one on the left (a log-axis) and one on the right (normal axis) to represent how wide the distribution is at the low values. (The function I use is attached, in case it is of interest to anyone. It is just an adaptation done quickly from a function by Araja.) The type of histogram I get is this:
I would like to add a colormap under the x-axis, like the one we can see here:
Anybody knows how to do so?
Thank you in advance!

採用された回答

Steven Lord
Steven Lord 2020 年 3 月 18 日
Call colorbar with the 'southoutside' location as shown in the "Add Horizontal Colorbar to Graph" example on the documentation page.

その他の回答 (2 件)

darova
darova 2020 年 3 月 18 日
contourf(peaks(60))
colormap cool
colorbar('location','southoutside')

Olfa Lopez
Olfa Lopez 2020 年 3 月 18 日
Here is how I managed to make the colorbar take the space of the x-axis, if it can help someone someday:
original_axes_pos = get(hAx2,'Position');
colormap gray
colorbar('location','southoutside',...
'Ticks',[],...
'TickLabels',{''})
set(hAx2,'Position',original_axes_pos);

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by