Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 8 additions & 24 deletions examples/gallery/images/cross_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
from pygmt.params import Axis, Box, Frame, Position

# Define region of study area
# lon_min, lon_max, lat_min, lat_max in degrees East and North
region_map = [122, 149, 30, 49]

# Chose a survey line with start point A and end point B
lonA, latA, lonB, latB = 126, 42, 146, 40 # noqa: N816

# Create a new pygmt.Figure instance
fig = pygmt.Figure()

fig = pygmt.Figure()
# ----------------------------------------------------------------------------
# Bottom: Map of elevation in study area

Expand Down Expand Up @@ -71,12 +69,8 @@
# Shift plot origin to the top by the height of the map ("+h") plus 1.5 centimeters
fig.shift_origin(yshift="h+1.5c")

fig.basemap(
region=[0, 15, -8000, 6000], # xmin, xmax, ymin, ymax
# Cartesian projection with a width of 12 centimeters and a height of 3 centimeters
projection="X12c/3c",
frame=0,
)
# Cartesian projection with a width of 12 centimeters and a height of 3 centimeters
fig.basemap(region=[0, 15, -8000, 6000], projection="X12c/3c", frame=0)

# Add labels "A" and "B" for the start and end points of the survey line
fig.text(
Expand All @@ -99,22 +93,12 @@
# new column "elevation" to the pandas.DataFrame
track_df = pygmt.grdtrack(grid=grid_map, points=track_df, newcolname="elevation")

# Plot water masses
fig.plot(
x=[0, 15],
y=[0, 0],
fill="lightblue", # Fill the polygon in "lightblue"
pen="0.25p,black,solid", # Draw a 0.25-point thick, black, solid outline
close="+y-8000", # Force closed polygon
)
# Plot water masses down to -8000 meters below sea level as a light blue area.
fig.fill_between(x=[0, 15], y=[0, 0], y2=-8000, pen="0.25p", fill="lightblue")

# Plot elevation along the survey line
fig.plot(
x=track_df.p,
y=track_df.elevation,
fill="gray",
pen="1p,red,solid",
close="+y-8000",
# Plot elevation along the survey line, filled down to -8000 meters below sea level.
fig.fill_between(
x=track_df.p, y=track_df.elevation, y2=-8000, pen="1p,red", fill="gray"
)

# Add map frame
Expand Down
Loading