colorbar tick labels -string above and below, remove ticks
20 views (last 30 days)
Show older comments
I am trying to reproduce the colorbar below for my chart.
Below is my current chart...
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)
0 Comments
Answers (1)
Voss
on 1 May 2022
Edited: Voss
on 1 May 2022
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');
0 Comments
See Also
Categories
Find more on Graphics Object Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!