MATLAB
Overlay Point Graph
and Color Band on Contour Plot
Author: Galaxy 8 – Chen Xiaoben
Contact Email: [email protected]
Data:Meteorological data, random custom defined by rand function

Part 1
clear;clc
%%%% Overlay continuous colors (within the range of meteorological data) on the original filled contour plot and display an independent colorbar for meteorological data (not shared with the base map colorbar)
load('typeground.mat')
figure(2)
axes1 = axes('Position',[0.2190625,0.193333333333334,0.5621875,0.738333333333336]); %%% Set the position of the first graph
hold on
contourf(typelon,typelat,typeground') %%% Base map filled data, can replace with your own data
box on % Turn on box
hidden off
hold on
plot(VarName1,VarName2,'LineWidth',1,'Color','black' ); %% Boundary data
hold on
axis([75,105,25,40]) % Set the size of the x-axis and y-axis frame
set(gca,'YTick',[25:5:40]) % x-axis range 1-6, interval 1
set(gca,'XTick',[75:10:105]) % y-axis range 0-700, interval 100
set(gca,'yticklabel',{'25°N','30°N','35°N','40°N'})% y-axis scale
set(gca,'xticklabel',{'75°E','85°E','95°E','105°E'})% x-axis scale
set(gca,'LineWidth',1,'XMinorTick','on','YMinorTick','on'); %% Turn on double boundary
hold on

Part 2
%%% Set text details
annotation('textbox',...
[0.250153645833333 0.194608066126979 0.121614583333333 0.0478841870824054],...
'String',{'Glaciers and lakes'},...
'FontSize',12,...
'FontName','Arial',...
'EdgeColor',[1 1 1]);
annotation('textbox',...
[0.250283854166667 0.203333333333334 0.179924479166666 0.068579017264275],...
'String',{'Unfrozen ground'},...
'FontSize',12,...
'FontName','Arial',...
'FitBoxToText','off',...
'EdgeColor',[1 1 1]);
annotation('textbox',...
[0.251651041666667 0.262222222222223 0.0358489583333331 0.0402213368747218],...
'String',{'SFG'},...
'FontSize',12,...
'FontName','Arial',...
'FitBoxToText','off',...
'EdgeColor','none');
annotation('textbox',...
[0.25178125 0.307246569278439 0.0603281250000001 0.0247011952191232],...
'String','Permafrost',...
'FontSize',12,...
'FontName','Arial',...
'FitBoxToText','off',...
'EdgeColor',[1 1 1]);

Part 3
%% Set square colors
annotation('textbox',...
[0.2320546875 0.301668880035412 0.0140390625 0.0155378486055759],...
'FitBoxToText','off',...
'BackgroundColor',[1 1 1]);
annotation('textbox',...
[0.2318359375 0.272248782647189 0.0134765625 0.0155378486055781],...
'FitBoxToText','off',...
'BackgroundColor',[0.701960784313725 0.8 0.8]);
annotation('textbox',...
[0.2318359375 0.241088977423638 0.0134765625 0.0155378486055756],...
'FitBoxToText','off',...
'BackgroundColor',[0 0 0]);
annotation('textbox',...
[0.2318359375 0.212045152722444 0.013671875 0.0151394422310755],...
'FitBoxToText','off',...
'BackgroundColor',[0.341176470588235 0.349019607843137 0.501960784313725]);

Part 4
%title('(a)'); %%% Set title below
%ax = gca;
%ax.TitleHorizontalAlignment = 'left';
axes2 =axes('Position',[0.2190625,0.193333333333334,0.5621875,0.738333333333336]); %% Set the second position with the same frame as before
hold on
axis([75,105,25,40]) %% Set the size of the x-axis and y-axis frame
lat=29+rand(1,100)*8; %%% Randomly generate numbers between 29-37 for our latitude.
lon=82+rand(1,100)*20; %%% Randomly generate numbers between 82 - 102 for our longitude
T=rand(1,100)*10-5; %%% Randomly generate numbers between -5- 5 for our temperature data
h_2 = scatter(axes2,lon,lat,100,T,'filled'); %%% Meteorological data point graph, 100 is the size
colorbar(axes2,'location','west'); %%% Colorbar position
box off %% All following settings must be turned off to draw another colorbar
axis off
hidden off
Sent from the backend:Group Chat QR Code,
Join the group chat by scanning the QR code,
Data is shared daily in the group
Edited by: Zhi Zhi