-
Notifications
You must be signed in to change notification settings - Fork 3
/
mf_plot_dom2.m
155 lines (102 loc) · 5.41 KB
/
mf_plot_dom2.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
% --------------------------------------------------------------------
% function to plot domain data
% --------------------------------------------------------------------
function [] = mf_plot_dom2(lon,lat,var,var_sign,caxis_dom,colormap_dom, flag_sp, flag_cb, panel, experiment, cbcaption)
% note
% flag_cb = 0; no colorbar
% 1: standard colorbar
% 2: thin colorbar southoutside
% invoke globals
global island
% --------------------------------------------------------------------
% Initialisation
% --------------------------------------------------------------------
% Set grid characteristics - whole domain
lat_min_dom = -70.0;
lat_max_dom = 80.0;
lon_min_dom = -177.5;
lon_max_dom = 177.5;
% set model resolution
res_lat = 0.9;
res_lon = 1.25;
% set sea color
seacolor = [0.9 0.9 0.9]; % light grey
% --------------------------------------------------------------------
% manipulations: hatching
% hatch insignificant pixels only if the sum of their indices is even
% --------------------------------------------------------------------
% if no significance mask is given, assume all pixels significant
if isempty(var_sign)
var_sign = ones(size(var));
end
% retain only insignificant values on land
var_insign = NaN(size(var_sign));
var_insign(var_sign == 0) = 1;
% do not consider potential significant changes over oceans
var_insign(~island) = NaN;
% generate checkerboard matrix
[nlat, nlon] = size(lat);
checkerboard = zeros(nlat, nlon); % "wide" checkerboard - perfect
checkerboard(1:3:nlat, 1:3:nlon) = 1;
checkerboard(3:3:nlat, 2:3:nlon) = 1;
checkerboard(2:3:nlat, 3:3:nlon) = 1;
% to have less lines, hatch insignificant pixels only if the sum of their indices is even
var_insign(checkerboard == 0) = NaN;
% prepare for hatching out
lon_insign = lon.*var_insign;
lat_insign = lat.*var_insign;
lon_insign = lon_insign(~isnan(lon_insign));
lat_insign = lat_insign(~isnan(lat_insign));
lon_insign = [lon_insign' - res_lon/2; lon_insign' + res_lon/2]; % plotting these gives diagonal over the pixel
lat_insign = [lat_insign' - res_lat/2; lat_insign' + res_lat/2];
% --------------------------------------------------------------------
% Visualisation
% --------------------------------------------------------------------
% design figure
if flag_sp == 0
figure('OuterPosition',[100 200 800 500]);
set(gcf, 'color', 'w');
set(gca,'color','w');
end
% Initialise grid and projection
m_proj('Equidistant Cylindrical','long',[lon_min_dom lon_max_dom],'lat',[lat_min_dom lat_max_dom]); % generate Equidistant Cylindrical projection (alternatives: Miller or Mercator)
m_grid('box','on','tickdir','in','color',[0, 0, 0], 'Fontweight', 'Bold', 'FontSize', 11, 'linewidth', 1.5, 'linestyle', 'none'); hold on; % draw grid with normal box
% set shading flat and ignore warnings this generates - necessary only for writing text on maps
shading flat; % set shading flat so that you can still plot text on the map
warning('off','all');
% plot light grey background
var(island==0) = NaN;
hback = m_pcolor(lon - res_lon/2, lat + res_lat/2, ones(size(var))); hold on;
set(hback, 'edgecolor', 'none', 'facecolor', seacolor);
% plot data
g = m_pcolor(lon - res_lon/2, lat + res_lat/2, var); % with shading flat will draw a panel between the (i,j),(i+1,j),(i+1,j+1),(i,j+1) coordinates of the lon/lat matrices with a color corresponding to the data value at (i,j).
set(g, 'edgecolor', 'none'); % remove black grid around pixels
set(gca, 'Fontsize', 14, 'Fontweight', 'Bold'); % set axes properties
caxis(caxis_dom); % set colorscale axes
colormap(colormap_dom); mf_freezeColors; % select colormap and freeze it
if flag_cb == 1
colorbar('Fontsize', 14, 'Fontweight', 'Bold'); hold on;
cbfreeze; mf_freezeColors;
elseif flag_cb == 2
c=colorbar('location', 'SouthOutside', 'Fontsize', 14, 'Fontweight', 'Bold', 'TickLength', [0 0]); hold on;
y1=get(gca,'position');
y=get(c,'Position');
y(4)=0.03;
set(c,'Position',y)
set(gca,'position',y1)
mf_freezeColors;
end
hold on;
% plot hatching
m_plot(lon_insign,lat_insign, '--', 'color', [0.8 0.8 0.8], 'linewidth', 1); hold on; % hatch over insignificant areas
% plot coasts
m_gshhs('cc','color','k'); % add coastline
% add text
m_text(-175,81,panel,'ver','bottom','hor','left', 'Fontweight', 'Bold', 'Fontsize', 12); hold on;
m_text(175,81,experiment,'ver','bottom','hor','right', 'Fontweight', 'Bold', 'Fontsize', 11); hold on;
if flag_cb == 1
m_text(240,0,cbcaption,'ver','bottom','hor','center', 'Fontweight', 'Bold', 'Fontsize', 12,'rotation',-90); hold off;
elseif flag_cb == 2
m_text(0,-125,cbcaption,'ver','bottom','hor','center', 'Fontweight', 'Bold', 'Fontsize', 12); hold off;
end
end