outfn = 'ex2HL_arrows';
% must single quotaion
%% basemap
gmt(['pscoast -R70/150/0/60 -JM15c -Ba -A4000 -N1
-W0.25p,black -K > ' outfn
'.ps'])
%% plot 12 Cartesian vectors with different
lengths
x = linspace(109, 109, 12)';
y = linspace(45, 55, 12)';
direction = zeros(size(x));
length = linspace(0.5, 1.5, 12)';
% Cartesian vectors (v) with red pen and fill (+g, +p),
vector head at
% end (+e), and 40 degree angle (+a) with no indentation
for vector head (+h)
style =
'v0.2c+e+a40+gred+h0+p1p,red';
vector = [x y direction length];
% gmt('psxy', ['-R20/60/-180/0 -JM12c -W1p,red -S' style
' > ' outfn '.ps'], vector);
gmt(['psxy -R -J -Ba -W1p,red -S' style
' -K -O >> ' outfn '.ps'],
vector);
txt = gmt('record', [113, 43],
'CARTESIAN');
gmt(['pstext -R -J -F+f13p,Helvetica-Bold,red -K -O
>> ' outfn '.ps'], txt);
%% plot 7 math angle arcs with different
radii
num = 7;
x = linspace(95, 95, num)'; % x coordinates of the
center
y = linspace(33, 33, num)'; % y coordinates
of the center
radius = 1.8 - 0.2 * (0 : num - 1)';%
radius
startdir = linspace(90, 90, num)'; % start
direction in degrees
stopdir = 180 + 40 * (0 : num - 1)'; % stop
direction in degrees
%# data for circular vectors
data = [x y radius startdir stopdir];
arcstyle = 'm0.5c+ea'; %
Circular vector (m) with an arrow at end
gmt(['psxy -R -J -Gred3 -W1.5p,black -S'
arcstyle ' -K -O >> ' outfn '.ps'],
data)
txt = gmt('record', [95, 42],
'CIRCULAR');
gmt(['pstext -R -J -F+f13p,Helvetica-Bold -K -O
>> ' outfn '.ps'], txt);
%% plot geographic vectors using
endpoints
PEK = [116.41, 39.9]; %
Peking
XAN = [108.9, 34.3]; %
Xi'an
XJG = [87.62, 43.79]; %
XinJiang
KMG = [102.71, 25.04]; %
KunMing
city = [PEK; XAN; XJG; KMG];
for i = 1 : size(city,
1)
gmt(['psxy -R -J -Sc0.1c -K
-O >> ' outfn '.ps'] , city(i,
:));
txt = gmt('record',
city(i, :) , ['city-' num2str(i)]);
gmt(['pstext -R -J
-F+f9p,Times-Roman -K -O >> ' outfn
'.ps'], txt);
end
% `=` means geographic vectors.
% With the modifier '+s', the input data should contain
coordinates of start
% and end points
style =
'=0.5c+s+e+a30+gblue+h0.5+p1p,blue';
data = [[PEK XAN]; [PEK XJG]; [PEK
KMG]];
gmt(['psxy -R -J -S' style '
-W1.0p,blue -K -O >> ' outfn '.ps'],
data);
% txt = {[110, 30], 'CIRCULAR'}; % not
works
txt = gmt('record', [125, 40],
'GEOGRAPHIC');
gmt(['pstext -R -J -F+f13p,Helvetica-Bold,blue -O
>> ' outfn '.ps'], txt);
%gmt(['pstext -R -J -O >> ' outfn '.ps'],
txt);
gmt(['psconvert -A -Tg -E600 ' outfn
'.ps']);
gmt(['psconvert -A -Tgf ' outfn
'.ps']);
gmt('destroy');
open([outfn '.pdf']);
|