|
19 | 19 | # lon_min, lon_max, lat_min, lat_max in degrees East and North
|
20 | 20 | region_map = [122, 149, 30, 49]
|
21 | 21 |
|
| 22 | +# Chose a survey line with start point A and end point B |
| 23 | +lonA, latA, lonB, latB = 126, 42, 146, 40 # noqa: N816 |
| 24 | + |
22 | 25 | # Create a new pygmt.Figure instance
|
23 | 26 | fig = pygmt.Figure()
|
24 | 27 |
|
|
39 | 42 | fig.colorbar(
|
40 | 43 | # Place the colorbar inside the plot (lowercase "j") in the Bottom Right (BR)
|
41 | 44 | # corner with an offset ("+o") of 0.7 centimeters and 0.3 centimeters in x- or y-
|
42 |
| - # directions, respectively; move the x label above the horizontal colorbar ("+ml") |
| 45 | + # directions, respectively; move the x-label above the horizontal colorbar ("+ml") |
43 | 46 | position="jBR+o0.7c/0.8c+h+w5c/0.3c+ml",
|
44 | 47 | # Add a box around the colobar with a fill ("+g") in "white" color and a
|
45 | 48 | # transparency ("@") of 30 % and with a 0.8-points thick, black, outline ("+p")
|
46 | 49 | box="+gwhite@30+p0.8p,black",
|
47 |
| - # Add x and y labels ("+l") |
| 50 | + # Add x- and y-labels ("+l") |
48 | 51 | frame=["x+lElevation", "y+lm"],
|
49 | 52 | )
|
50 | 53 |
|
51 |
| -# Choose a survey line |
52 |
| -fig.plot( |
53 |
| - x=[126, 146], # Longitude in degrees East |
54 |
| - y=[42, 40], # Latitude in degrees North |
55 |
| - # Draw a 2-points thick, red, dashed line for the survey line |
56 |
| - pen="2p,red,dashed", |
57 |
| -) |
| 54 | +# Plot the survey line |
| 55 | +fig.plot(x=[lonA, lonB], y=[latA, latB], pen="1p,red,solid") |
58 | 56 |
|
59 | 57 | # Add labels "A" and "B" for the start and end points of the survey line
|
60 | 58 | fig.text(
|
61 |
| - x=[126, 146], |
62 |
| - y=[42, 40], |
| 59 | + x=[lonA, lonB], |
| 60 | + y=[latA, latB], |
63 | 61 | text=["A", "B"],
|
64 |
| - offset="0c/0.2c", # Move text 0.2 centimeters up (y-direction) |
65 |
| - font="15p", # Use a font size of 15 points |
| 62 | + offset="0c/0.3c", # Move text 0.2 centimeters up (y-direction) |
| 63 | + font="15p,red", # Use a red font with a size of 15 points |
66 | 64 | )
|
67 | 65 |
|
68 | 66 | # ----------------------------------------------------------------------------
|
|
75 | 73 | region=[0, 15, -8000, 6000], # x_min, x_max, y_min, y_max
|
76 | 74 | # Cartesian projection with a width of 12 centimeters and a height of 3 centimeters
|
77 | 75 | projection="X12c/3c",
|
78 |
| - # Add annotations ("a") and ticks ("f") as well as labels ("+l") at the west or |
79 |
| - # left and south or bottom sides ("WSrt") |
80 |
| - frame=["WSrt", "xa2f1+lDistance+u°", "ya4000+lElevation / m"], |
| 76 | + frame=0, |
81 | 77 | )
|
82 | 78 |
|
83 | 79 | # Add labels "A" and "B" for the start and end points of the survey line
|
|
86 | 82 | y=[7000, 7000],
|
87 | 83 | text=["A", "B"],
|
88 | 84 | no_clip=True, # Do not clip text that fall outside the plot bounds
|
89 |
| - font="10p", # Use a font size of 10 points |
| 85 | + font="10p,red", |
90 | 86 | )
|
91 | 87 |
|
92 | 88 | # Generate points along a great circle corresponding to the survey line and store them
|
93 | 89 | # in a pandas.DataFrame
|
94 | 90 | track_df = pygmt.project(
|
95 |
| - center=[126, 42], # Start point of survey line (longitude, latitude) |
96 |
| - endpoint=[146, 40], # End point of survey line (longitude, latitude) |
| 91 | + center=[lonA, latA], # Start point of survey line (longitude, latitude) |
| 92 | + endpoint=[lonB, latB], # End point of survey line (longitude, latitude) |
97 | 93 | generate=0.1, # Output data in steps of 0.1 degrees
|
98 | 94 | )
|
99 | 95 |
|
|
106 | 102 | x=[0, 15],
|
107 | 103 | y=[0, 0],
|
108 | 104 | fill="lightblue", # Fill the polygon in "lightblue"
|
109 |
| - # Draw a 0.25-points thick, black, solid outline |
110 |
| - pen="0.25p,black,solid", |
| 105 | + pen="0.25p,black,solid", # Draw a 0.25-points thick, black, solid outline |
111 | 106 | close="+y-8000", # Force closed polygon
|
112 | 107 | )
|
113 | 108 |
|
114 | 109 | # Plot elevation along the survey line
|
115 | 110 | fig.plot(
|
116 | 111 | x=track_df.p,
|
117 | 112 | y=track_df.elevation,
|
118 |
| - fill="gray", # Fill the polygon in "gray" |
119 |
| - # Draw a 1-point thick, black, solid outline |
120 |
| - pen="1p,black,solid", |
121 |
| - close="+y-8000", # Force closed polygon |
| 113 | + fill="gray", |
| 114 | + pen="1p,red,solid", |
| 115 | + close="+y-8000", |
122 | 116 | )
|
123 | 117 |
|
| 118 | +# Add map frame |
| 119 | +# Add annotations ("a") and ticks ("f") as well as labels ("+l") at the west or left |
| 120 | +# and south or bottom sides ("WSrt") |
| 121 | +fig.basemap(frame=["WSrt", "xa2f1+lDistance+u°", "ya4000+lElevation / m"]) |
| 122 | + |
124 | 123 | fig.show()
|
0 commit comments