-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathetsPlot.m
More file actions
44 lines (34 loc) · 1.54 KB
/
etsPlot.m
File metadata and controls
44 lines (34 loc) · 1.54 KB
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
function etsMap = etsPlot(x, y, z)
%input: Latitude (x), longitude (y) of the ets event point, and time (z) of the ets event
%output: Map area's with ets sampling event point
%Scientific Color Map (crameri function): https://github.com/chadagreene/crameri.git
%Crameri, Fabio. (2021). Scientific colour maps (7.0.1). Zenodo. https://doi.org/10.5281/zenodo.5501399
% Convert the time variable z to datetime
z = datetime(z, 'InputFormat', 'yyyy-MM-dd HH:mm:ss');
% Create a colormap based on the min and max time values
min_time = min(z);
max_time = max(z);
time_range = max_time - min_time;
time_fraction = (z - min_time) / time_range;
% Assign colors based on the time_fraction
cmap = crameri('vik', 256);
colors = interp1(linspace(0, 1, size(cmap, 1)), cmap, time_fraction);
% Create a geoaxes object to plot on
etsMap = geoaxes;
hold(etsMap, 'on');
% Plot the data with geoscatter
geoscatter(etsMap, x, y, 20, colors, 'filled', 'o', 'MarkerEdgeColor', 'k');
% Add a colorbar with appropriate limits and ticks
cbar = colorbar(etsMap, 'Location', 'eastoutside');
caxis(etsMap, [datenum(min_time), datenum(max_time)]);
cbar.Ticks = linspace(datenum(min_time), datenum(max_time), 6);
cbar.TickLabels = datestr(cbar.Ticks, 'yyyy-mm-dd');
colormap(etsMap, cmap);
% Specify the x,y limit for the lat and lon
%geolimits([min(x)-0.25 max(x)]+0.15,[min(y) max(y)]) %Change accordingly
geolimits(etsMap, [43.75, 46.75], [-124, -122]); %for onshore casc
geobasemap(etsMap, 'grayterrain'); %change accordingly
% Add labels
title(etsMap, 'Tremor');
hold(etsMap, 'off');
end