# How plot the right scale for earthquake hypocenter cross section

**URL:** <https://forum.generic-mapping-tools.org/t/how-plot-the-right-scale-for-earthquake-hypocenter-cross-section/4643>\
**Category:** PyGMT Q&A\
**Tags:** gmt\
**Created:** [January 28, 2024, 5:39am UTC](https://forum.generic-mapping-tools.org/t/how-plot-the-right-scale-for-earthquake-hypocenter-cross-section/4643 "2024-01-28T05:39:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![calvs](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/calvs/32/3328_2.png) [@calvs](https://forum.generic-mapping-tools.org/u/calvs)\
**Post date:** [January 28, 2024, 5:39am UTC](https://forum.generic-mapping-tools.org/t/how-plot-the-right-scale-for-earthquake-hypocenter-cross-section/4643/1 "2024-01-28T05:39:12Z")

</div>

My desire is to produce a cross section that has the right scale for the earthquake hypocenters, with respect to the x and y axis. My plot seems to show that my y-axis is compressed, making it difficult to plot convergence plate thickness as shown in the figure. I also attached the script

 ![section (1)](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/b/bdf43c6cd3540cebfda4873e794705e295c822df.png)

#### GMT Script

```
gmt begin section png

gmt makecpt -Cseis -T0/650/100 -D -Z -H > res.cpt
# Extract data and calculate circle sizes based on magnitude
awk 'NR>1 {print $3,$2,$4,$4,$5}' solomoncatalog.txt > mag7.txt

gmt subplot begin 3x2 -Fs14c/7c -A -V

# Plot earthquakes with mag < 7.0 in blue
gmt project extracted_below_mag7.txt -C153.2/-7 -E155.5/-4.4 -Lw -W-0.2/0.2 -Fyz > projected_input_below_mag7.txt
awk '{print $1,$2,$3,0.04*$4}' projected_input_below_mag7.txt | gmt plot -JX14c/-7c -R-7/-4.4/-50/650 -BWesn -Bya200f40+l"Depth (km)" -Bxa2f0.5 -Sc -W0.5p -Cres.cpt -Gblue
awk '$4>=7.0 {print $1,$2}' projected_input_below_mag7.txt | gmt plot -Sx1 -W0.5p
cat<<EOF> legend.txt
-4.8 200 0 3
-4.8 250 0 4
-4.8 300 0 5
-4.8 350 0 6
-4.8 400 0 7
EOF
awk '{print $1,$2,0.04*$4}' legend.txt | gmt plot -Sc -W0.5p
echo "lon = 153.2 to 155.5" | gmt text -F+cBL+f16p,4,black -Dj1c/1c
echo "lat = -7.0 to -4.4" | gmt text -F+cBL+f16p,4,black -Dj1c/0.5c

cat <<EOF > legend.txt
-4.8 200 0 3
-4.8 250 0 4
-4.8 300 0 5
-4.8 350 0 6
-4.8 400 0 7
EOF

# Add a line to include the text "Magnitude Scale"
#echo "-4.8 420 Magnitude Scale" >> legend.txt

# Use awk to print coordinates and scaled magnitudes, then plot with GMT
awk '{print $1,$2,0.04*$4}' legend.txt | gmt plot -Sc -W0.5p

# Add the legend title "Magnitude Scale" above the points
echo "-4.7 140 Mag Scale" | gmt text -F+f16p,4,black -Dj0.1c/0.1c
echo "-4.7 200 M3" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-4.7 250 M4" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-4.7 300 M5" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-4.7 350 M6" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-4.7 400 M7" | gmt text -F+f12p,4,black -Dj0.1c/0.1c

gmt subplot set 1 # transect along lon = 153
gmt project extracted_below_mag7.txt -C154.5/-9 -E157.1/-6.2 -Lw -W-0.2/0.2 -Fyz > projected_input_below_mag7.txt
awk '{print $1,$2,$3,0.04*$4}' projected_input_below_mag7.txt | gmt plot -JX14c/-7c -R-9/-6.2/-50/650 -BwESn -Bya200f40 -Bxa2f0.5 -Sc -W0.5p -Cres.cpt -Gblue
awk '$4>=7.0 {print $1,$2}' projected_input_below_mag7.txt | gmt plot -Sx1 -W0.5p

cat<<EOF> legend.txt
-6.5 200 0 3
-6.5 250 0 4
-6.5 300 0 5
-6.5 350 0 6
-6.5 400 0 7
EOF
awk '{print $1,$2,0.04*$4}' legend.txt | gmt plot -Sc -W0.5p
echo "lon = 154.5 to 157.1" | gmt text -F+cBL+f16p,4,black -Dj1c/1c
echo "lat = -9.0 to -6.2" | gmt text -F+cBL+f16p,4,black -Dj1c/0.5c

at <<EOF > legend.txt
-6.5 200 0 3
-6.5 250 0 4
-6.5 300 0 5
-6.5 350 0 6
-6.5 400 0 7
EOF

# Use awk to print coordinates and scaled magnitudes, then plot with GMT
awk '{print $1,$2,0.04*$4}' legend.txt | gmt plot -Sc -W0.5p

# Add the legend title "Magnitude Scale" above the points
echo "-6.5 140 Mag Scale" | gmt text -F+f16p,4,black -Dj0.1c/0.1c
echo "-6.4 200 M3" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-6.4 250 M4" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-6.4 300 M5" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-6.4 350 M6" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-6.4 400 M7" | gmt text -F+f12p,4,black -Dj0.1c/0.1c

gmt subplot set 2 # transect along lon = 154
gmt project extracted_below_mag7.txt -C157.4/-10 -E159.5/-7.2 -Lw -W-0.2/0.2 -Fyz > projected_input_below_mag7.txt
awk '{print $1,$2,$3,0.04*$4}' projected_input_below_mag7.txt | gmt plot -JX14c/-7c -R-10/-7.2/-50/650 -BWesn -Bya200f40+l"Depth (km)" -Bxa2f0.5 -Sc -W0.5p -Cres.cpt -Gblue

awk '$4>=7.0 {print $1,$2}' projected_input_below_mag7.txt | gmt plot -Sx1 -W0.5p

cat<<EOF> legend.txt
-7.6 200 0 3
-7.6 250 0 4
-7.6 300 0 5
-7.6 350 0 6
-7.6 400 0 7
EOF

awk '{print $1,$2,0.04*$4}' legend.txt | gmt plot -Sc -W0.5p
echo "lon = 157.4 to 159.5" | gmt text -F+cBL+f16p,4,black -Dj1c/1c
echo "lat = -10.0 to -7.2" | gmt text -F+cBL+f16p,4,black -Dj1c/0.5c

at <<EOF > legend.txt
-9.0 200 0 3
-9.0 250 0 4
-9.0 300 0 5
-9.0 350 0 6
-9.0 400 0 7
EOF
# Use awk to print coordinates and scaled magnitudes, then plot with GMT
awk '{print $1,$2,0.04*$4}' legend.txt | gmt plot -Sc -W0.5p

# Add the legend title "Magnitude Scale" above the points
echo "-7.5 140 Mag Scale" | gmt text -F+f16p,4,black -Dj0.1c/0.1c
echo "-7.5 200 M3" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-7.5 250 M4" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-7.5 300 M5" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-7.5 350 M6" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-7.5 400 M7" | gmt text -F+f12p,4,black -Dj0.1c/0.1c

gmt subplot set 3 # transect along lon = 155
gmt project extracted_below_mag7.txt -C160/-11 -E161.6/-8.5 -Lw -W-0.2/0.2 -Fyz > projected_input_below_mag7.txt
awk '{print $1,$2,$3,0.04*$4}' projected_input_below_mag7.txt | gmt plot -JX14c/-7c -R-11/-8.5/-50/650 -BwESn -Bya200f40 -Bxa2f0.5 -Sc -W0.5p -Cres.cpt -Gblue
awk '$4>=7.0 {print $1,$2}' projected_input_below_mag7.txt | gmt plot -Sx1 -W0.5p

cat<<EOF> legend.txt
-8.8 200 0 3
-8.8 250 0 4
-8.8 300 0 5
-8.8 350 0 6
-8.8 400 0 7
EOF

awk '{print $1,$2,0.04*$4}' legend.txt | gmt plot -Sc -W0.5p
echo "lon = 160 to 161.6" | gmt text -F+cBL+f16p,4,black -Dj1c/1c # adding text
echo "lat = -11 to -8.5" | gmt text -F+cBL+f16p,4,black -Dj1c/0.5c

at <<EOF > legend.txt
-9.0 200 0 3
-9.0 250 0 4
-9.0 300 0 5
-9.0 350 0 6
-9.0 400 0 7
EOF

# Use awk to print coordinates and scaled magnitudes, then plot with GMT
awk '{print $1,$2,0.04*$4}' legend.txt | gmt plot -Sc -W0.5p

# Add the legend title "Magnitude Scale" above the points
echo "-8.8 140 Mag Scale" | gmt text -F+f16p,4,black -Dj0.1c/0.1c
echo "-8.7 200 M3" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-8.7 250 M4" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-8.7 300 M5" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-8.7 350 M6" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-8.7 400 M7" | gmt text -F+f12p,4,black -Dj0.1c/0.1c

gmt subplot set 4 # transect along lon = 156
#gmt project extracted.txt -C162.2/-12 -E163.5/-9.8 -Lw -W-0.2/0.2 -Fyz > projected_input.txt
#gmt plot projected_input.txt -JX14c/-7c -R-12/-9.8/-50/650 -BWeSn -Bya200f40+l"Depth (km)" -Bxa2f0.5 -Sc4.8p -W0.5p -Cres.cpt # ploting

gmt project extracted_below_mag7.txt -C162.2/-12 -E163.5/-9.8 -Lw -W-0.2/0.2 -Fyz > projected_input_below_mag7.txt
awk '{print $1,$2,$3,0.04*$4}' projected_input_below_mag7.txt | gmt plot -JX14c/-7c -R-12/-9.8/-50/650 -BWesn -Bya200f40+l"Depth (km)" -Bxa2f0.5 -Sc -W0.5p -Cres.cpt -Gblue
awk '$4>=7.0 {print $1,$2}' projected_input_below_mag7.txt | gmt plot -Sx1 -W0.5p

cat<<EOF> legend.txt
-10.1 200 0 3
-10.1 250 0 4
-10.1 300 0 5
-10.1 350 0 6
-10.1 400 0 7
EOF
awk '{print $1,$2,0.04*$4}' legend.txt | gmt plot -Sc -W0.5p
echo "lon = 162.2 to 163.5" | gmt text -F+cBL+f16p,4,black -Dj1c/1c # adding text
echo "lat = -12 to -9.8" | gmt text -F+cBL+f16p,4,black -Dj1c/0.5c

at <<EOF > legend.txt
-9.0 200 0 3
-9.0 250 0 4
-9.0 300 0 5
-9.0 350 0 6
-9.0 400 0 7
EOF

# Use awk to print coordinates and scaled magnitudes, then plot with GMT
awk '{print $1,$2,0.04*$4}' legend.txt | gmt plot -Sc -W0.5p

# Add the legend title "Magnitude Scale" above the points
echo "-10.1 140 Mag Scale" | gmt text -F+f16p,4,black -Dj0.1c/0.1c
echo "-10.02 200 M3" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-10.02 250 M4" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-10.02 300 M5" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-10.02 350 M6" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-10.02 400 M7" | gmt text -F+f12p,4,black -Dj0.1c/0.1c

gmt subplot set 5 # transect along lon = 157
gmt project extracted_below_mag7.txt -C164.6/-12.1 -E167.4/-11.3 -Lw -W-0.2/0.2 -Fyz > projected_input_below_mag7.txt
awk '{print $1,$2,$3,0.04*$4}' projected_input_below_mag7.txt | gmt plot -JX14c/-7c -R-12.1/-11.3/-50/650 -BwESn -Bya200f40 -Bxa2f0.5 -Sc -W0.5p -Cres.cpt -Gblue
awk '$4>=7.0 {print $1,$2}' projected_input_below_mag7.txt | gmt plot -Sx1 -W0.5p
cat<<EOF> legend.txt
-11.4 400 0 3
-11.4 450 0 4
-11.4 500 0 5
-11.4 550 0 6
-11.4 600 0 7
EOF
awk '{print $1,$2,0.04*$4}' legend.txt | gmt plot -Sc -W0.5p
echo "lon = 164.6 to 167.4 " | gmt text -F+cBL+f16p,4,black -Dj1c/1c # adding text
echo "lat = -12.1 to -11.3" | gmt text -F+cBL+f16p,4,black -Dj1c/0.5c

at <<EOF > legend.txt
-9.0 200 0 3
-9.0 250 0 4
-9.0 300 0 5
-9.0 350 0 6
-9.0 400 0 7
EOF

# Use awk to print coordinates and scaled magnitudes, then plot with GMT
awk '{print $1,$2,0.04*$4}' legend.txt | gmt plot -Sc -W0.5p

# Add the legend title "Magnitude Scale" above the points
echo "-11.4 350 Mag Scale" | gmt text -F+f16p,4,black -Dj0.1c/0.1c
echo "-11.37 400 M3" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-11.37 450 M4" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-11.37 500 M5" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-11.37 550 M6" | gmt text -F+f12p,4,black -Dj0.1c/0.1c
echo "-11.37 600 M7" | gmt text -F+f12p,4,black -Dj0.1c/0.1c

gmt subplot end

gmt colorbar -DJBC+e+w8c+o1c -Cres.cpt -Bxa100+L"depth(km)"

gmt end show

```

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [January 28, 2024, 12:37pm UTC](https://forum.generic-mapping-tools.org/t/how-plot-the-right-scale-for-earthquake-hypocenter-cross-section/4643/2 "2024-01-28T12:37:54Z")

</div>

> [@calvs](#):
>
> to produce a cross section that has the right scale for the earthquake hypocenters, with respect to the x and y axis. My plot seems to show that my y-axis is compressed

it is not 100% clear to me what exactly you want. If you just want to specify another X:Y scale, you can do it using `-Fs...` in your `gmt subplot begin` call and `-JX...` in the `gmt plot` calls. Like if you want square 7 cm x 7 cm plots, you could use `gmt subplot begin 3x2 -Fs7c -A -V` and  
`gmt plot -JX7c/-7c ...` in your subplots.

EDIT  
if you also want to have exactly the same scale for X axis on all plots, you need to specify identical span over X axis for each plot in `-R...`. Currently your Y span is exactly the same on all plots, 700 km, `-R.../-50/650`, but X span is variable, `-R-7/-4.4/...`, `-R-9/-6.2/...`, `-R-11/-8.5/...` etc

---

<div class="post-metadata">

**Author:** ![EJFielding](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/ejfielding/32/82_2.png) [@EJFielding](https://forum.generic-mapping-tools.org/u/EJFielding)\
**Post date:** [January 28, 2024, 9:44pm UTC](https://forum.generic-mapping-tools.org/t/how-plot-the-right-scale-for-earthquake-hypocenter-cross-section/4643/3 "2024-01-28T21:44:16Z")

</div>

@calvs Welcome to the GMT Forum. It seems that you have already done a lot of study on how to make your cross-section plots. You probably already looked at the documentation of the `gmt project` command ([https://docs.generic-mapping-tools.org/latest/project.html](https://docs.generic-mapping-tools.org/latest/project.html)). You are using `project` to project the hypocenters into a number of cross-sections that are at a variety of azimuths, but you are using the `project -Fyz` flag that writes out only the latitude of the points. To get cross-sections with more accurate scaling, I would recommend using the `project -Fpz` flag to get the distance `p` in kilometers along the profile line for each hypocenter. Then you will have equal units of kilometers for both the depth and distance along the cross-section and you can better adjust the scale of the x and y in your plots.
