colorbar tick labels -string above and below, remove ticks

2 ビュー (過去 30 日間)
aine gormley
aine gormley 2019 年 4 月 5 日
編集済み: Voss 2022 年 5 月 1 日
I am trying to reproduce the colorbar below for my chart.
sebastians.jpg
Below is my current chart...
colorbar.png
Below is my code for this, please can you advise?
figure()
set(gcf, 'color', 'w');
slopedelta_rolled=mean(mean_slope_txx_irr,3)-mean(mean_slope_txx_ctl,3);
temp = [deltatxx_theiry(:) slopedelta_rolled(:)];
temp(temp == 0) = NaN;
[Q,Qc] = hist3(temp,'Nbins',[100 100],'CDataMode','auto');
Qx = cell2mat(Qc(1));
Qy = cell2mat(Qc(2));
Q = Q';
Q = Q./trapz(Qy,trapz(Qx,Q,2));
surf(Qx,Qy,Q,'FaceColor','interp','EdgeColor','none')
xlim([-2.1 3.4])
ylim([-0.14 0.12])
grid off
set(gca, 'Fontsize', 12, 'Fontweight', 'Bold'); %added
ylabel('slope IRR - slope CTL [K yr^-^1]');
xlabel('mean IRR - mean CTL [K]');
cmap = jet(500);
cmap(1,:) = [1,1,1];
colormap(cmap);
h=colorbar;
set(h,'position',[.91 .34 .031 .475]) %[xposition yposition width height].
set(get(h,'ylabel'),'string','Point density');
set(h,'XTickLabel',{'Low',' ',' ',' ',' ','High',});
view(0,90)

回答 (1 件)

Voss
Voss 2022 年 5 月 1 日
編集済み: Voss 2022 年 5 月 1 日
f = figure();
set(gca(),'Visible','on');
n_colors = 64;
h = axes( ...
'Parent',f, ...
'Units','normalized', ...
'Position',[0.91 0.34 0.022 0.475], ...
'XTick',[], ...
'YTick',[], ...
'YAxisLocation','right', ...
'XLim',[0 1], ...
'YLim',[0 n_colors-1], ...
'Visible','off');
surface( ...
'Parent',h, ...
'XData',[0 1], ...
'YData',0:n_colors-1, ...
'ZData',zeros(n_colors,2), ...
'FaceColor','flat', ...
'CData',permute(jet(n_colors),[1 3 2]), ...
'EdgeColor','none')
text( ...
'Parent',h, ...
'Position',[0.5 0], ...
'String','Low', ...
'VerticalAlignment','top', ...
'HorizontalAlignment','center', ...
'FontName','NanumSquare', ...
'FontSize',12, ...
'FontWeight','bold');
text( ...
'Parent',h, ...
'Position',[0.5 n_colors], ...
'String','High', ...
'VerticalAlignment','bottom', ...
'HorizontalAlignment','center', ...
'FontName','NanumSquare', ...
'FontSize',12, ...
'FontWeight','bold');
text( ...
'Parent',h, ...
'Position',[1 n_colors/2], ...
'VerticalAlignment','top', ...
'HorizontalAlignment','center', ...
'Rotation',90, ...
'String','Point density', ...
'FontName','NanumSquare', ...
'FontSize',16, ...
'FontWeight','bold');

カテゴリ

Help Center および File ExchangeLabels and Styling についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by