Colorbar label outside image

7 views (last 30 days)
Francisco Ramirez
Francisco Ramirez on 13 Sep 2021
Answered: Image Analyst on 13 Sep 2021
Can't figure how to make the colorbar labels not being cut out of the image.
I have read about the .Layout.Tile property for colorbars, however I can't do that since I'm running on Matlab2020a and that feature was added in the 2020b version.
plot_1 = nan(size(importance)+1); plot_1(1:end-1,1:end-1) = importance;
plot_2 = nan(size(importance)+1); plot_2(1:end-1,1:end-1) = sm_pred;
plot_3 = nan(size(importance)+1); plot_3(1:end-1,1:end-1) = r_sq;
plot_4 = nan(size(importance)+1); plot_4(1:end-1,1:end-1) = sm2004;
plot_5 = nan(size(importance)+1); plot_5(1:end-1,1:end-1) = sm_bias;
plot_6 = nan(size(importance)+1); plot_6(1:end-1,1:end-1) = importance2;
plot_7 = nan(size(importance)+1); plot_7(1:end-1,1:end-1) = importance3;
Grd_dx = 0.04; Grd_dy = 0.04;
Grd_iref = 200; Grd_jref = 170;
Grd_ni = 360; Grd_nj = 360;
Grd_lonr = 22.80; Grd_latr = -11.25;
Grd_xlat1 = 66.00; Grd_xlon1 = -106.00;
Grd_xlat2 = 0.00; Grd_xlon2 = -16.00;
Grd_X=((0.5:(0.5+size(importance,1)))-Grd_iref)*Grd_dx+Grd_lonr;
Grd_Y=((0.5:(0.5+size(importance,2)))-Grd_jref)*Grd_dy+Grd_latr;
[Grd_rlon,Grd_rlat]=ndgrid(Grd_X,Grd_Y);
domain_proj=defaultm('pcarree');
domain_proj.origin=double([Grd_xlat1 Grd_xlon1 90-azimuth(Grd_xlat1,Grd_xlon1,Grd_xlat2,Grd_xlon2)]);
domain_proj=defaultm(domain_proj);
[Grd_lat,Grd_lon]=minvtran(domain_proj,deg2rad(Grd_rlon),deg2rad(Grd_rlat));
[Grd_rlonc,Grd_rlatc]=ndgrid(Grd_X(2:end)-0.5*Grd_dx,Grd_Y(2:end)-0.5*Grd_dy);
hex = ['#6b705c';'#a5a58d';'#b7b7a4';... %clay camo green
'#fec5bb';'#fcd5ce';'#fae1dd';'#f8edeb';... %hr pale pink
'#03045e';'#023e8a';'#0077b6';'#0096c7';... %st blue
'#ffd400';'#ffdd32';'#ffee99';'#fffae5';... %2m temp green
'#52b788';'#74c69d';'#95d5b2';'#95d5b2';... %water availability gold yellow
'#3dccc7';... %max spr swe
'#4281a4';... %mean snow melt
'#b69121';'#c9a227';'#dbb42c';... %sand brown
'#450920']; %topo magenta
map = sscanf(hex','#%2x%2x%2x',[3,size(hex,1)])'./ 255;
f1 = figure(1); % open a new figure window
x0=10;
y0=10;
width=3200;
height=1600;
set(gcf,'position',[x0,y0,width,height])
tiles = tiledlayout(1,3,'TileSpacing','none','Padding','compact');
title(tiles,{'Variables of importance','Top Layer Soil Moisture','Random forest models',mls},'FontSize',24);
nexttile(1); %Tile 1
title('Importance 1','FontSize',24);
axesm('pcarree','Frame','on','Grid','on','origin',domain_proj.origin,'FLonLimit',[min(Grd_X)-0.001 max(Grd_X)+0.001],'FLatLimit',[min(Grd_Y)-0.001 max(Grd_Y)+0.001]);
tightmap
surfm(Grd_lat,Grd_lon,plot_1)
geoshow('ne_10m_ocean.shp','FaceColor','w')
colormap(map)
caxis([1 25])
cb = colorbar('YTickLabel',...
{'Clay Level 1','Clay Level 2','Clay Level 3',...
'Relative Humidity 7d lag','Relative Humidity 14d lag','Relative Humidity 28d lag','Relative Humidity 90d lag',...
'Soil Temperature 7d lag','Soil Temperature 14d lag','Soil Temperature 28d lag','Soil Temperature 90d lag',...
'2m Temperature 7d lag','2m Temperature 14d lag','2m Temperature 28d lag','2m Temperature 90d lag',...
'Water Availability 01d','Water Availability 01d','Water Availability 01d','Water Availability 01d',...
'Max Spring SWE','Mean Spring Snowmelt',...
'Sand Level 1','Sand Level 2','Sand Level 3',...
'Topography'},...
'YTick',1:25,'Location','westoutside','TickDirection','in');
nexttile(2); %Tile 2
title('Importance 2','FontSize',24);
axesm('pcarree','Frame','on','Grid','on','origin',domain_proj.origin,'FLonLimit',[min(Grd_X)-0.001 max(Grd_X)+0.001],'FLatLimit',[min(Grd_Y)-0.001 max(Grd_Y)+0.001]);
tightmap
surfm(Grd_lat,Grd_lon,plot_6)
geoshow('ne_10m_ocean.shp','FaceColor','w')
colormap(map)
caxis([1 25])
nexttile(3); %Tile 3
title('Importance 3','FontSize',24);
axesm('pcarree','Frame','on','Grid','on','origin',domain_proj.origin,'FLonLimit',[min(Grd_X)-0.001 max(Grd_X)+0.001],'FLatLimit',[min(Grd_Y)-0.001 max(Grd_Y)+0.001]);
tightmap
surfm(Grd_lat,Grd_lon,plot_7)
geoshow('ne_10m_ocean.shp','FaceColor','w')
colormap(map)
caxis([1 25])

Answers (1)

Image Analyst
Image Analyst on 13 Sep 2021
Maybe try using subplot() and imshow() instead of tiledlayout and nexttile

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!