|
2 | 2 | Envelope
|
3 | 3 | ========
|
4 | 4 |
|
5 |
| -The ``close`` parameter of the :meth:`pygmt.Figure.plot` method can be |
6 |
| -used to build a symmetrical or an asymmetrical envelope. The user can |
7 |
| -give either the deviations or the bounds in y-direction. For the first |
8 |
| -case append ``"+d"`` or ``"+D"`` and for the latter case ``"+b"``. |
| 5 | +The ``close`` parameter of the :meth:`pygmt.Figure.plot` method can be used to build a |
| 6 | +symmetrical or an asymmetrical envelope. The user can give either the deviations or the |
| 7 | +bounds in y-direction. For the first case append ``"+d"`` or ``"+D"`` and for the latter |
| 8 | +case ``"+b"``. |
9 | 9 | """
|
10 | 10 |
|
11 | 11 | # %%
|
12 | 12 | import pandas as pd
|
13 | 13 | import pygmt
|
14 | 14 |
|
15 |
| -# Define a pandas DataFrame with columns for x and y as well as the |
16 |
| -# lower and upper deviations |
| 15 | +# Define a pandas.DataFrame with columns for x and y as well as the lower and upper |
| 16 | +# deviations |
17 | 17 | df_devi = pd.DataFrame(
|
18 | 18 | data={
|
19 | 19 | "x": [1, 3, 5, 7, 9],
|
|
23 | 23 | }
|
24 | 24 | )
|
25 | 25 |
|
26 |
| -# Define the same pandas DataFrame but with lower and upper bounds |
| 26 | +# Define the same pandas.DataFrame but with lower and upper bounds |
27 | 27 | df_bound = pd.DataFrame(
|
28 | 28 | data={
|
29 | 29 | "x": [1, 3, 5, 7, 9],
|
|
34 | 34 | )
|
35 | 35 |
|
36 | 36 |
|
37 |
| -# Create Figure instance |
38 | 37 | fig = pygmt.Figure()
|
39 | 38 |
|
40 | 39 | # -----------------------------------------------------------------------------
|
|
55 | 54 | )
|
56 | 55 |
|
57 | 56 | # Plot the data points on top
|
58 |
| -fig.plot( |
59 |
| - data=df_devi, |
60 |
| - style="c0.2c", # Use circles with a diameter of 0.2 centimeters |
61 |
| - pen="1p,gray30", |
62 |
| - fill="darkgray", |
63 |
| -) |
| 57 | +fig.plot(data=df_devi, style="c0.2c", pen="1p,gray30", fill="darkgray") |
64 | 58 |
|
65 |
| -# Shift plot origin 11 centimeters in x direction |
66 |
| -fig.shift_origin(xshift="11c") |
| 59 | +# Shift plot origin by the figure width ("w") plus 1 centimeter in x direction |
| 60 | +fig.shift_origin(xshift="w+1c") |
67 | 61 |
|
68 | 62 | # -----------------------------------------------------------------------------
|
69 | 63 | # Middle
|
|
77 | 71 | fig.plot(
|
78 | 72 | data=df_devi,
|
79 | 73 | fill="gray@50",
|
80 |
| - # Add an outline around the envelope |
81 |
| - # Here, a dashed pen ("+p") with 0.5-points thickness and |
82 |
| - # "gray30" color is used |
| 74 | + # Add an outline around the envelope. Here, a dashed pen ("+p") with 0.5-points |
| 75 | + # thickness and "gray30" color is used |
83 | 76 | close="+D+p0.5p,gray30,dashed",
|
84 | 77 | pen="1p,gray30",
|
85 | 78 | )
|
86 | 79 |
|
87 |
| -# Plot the data points on top |
88 | 80 | fig.plot(data=df_devi, style="c0.2c", pen="1p,gray30", fill="darkgray")
|
89 | 81 |
|
90 |
| -# Shift plot origin 11 centimeters in x-direction |
91 |
| -fig.shift_origin(xshift="11c") |
| 82 | +fig.shift_origin(xshift="w+1c") |
92 | 83 |
|
93 | 84 | # -----------------------------------------------------------------------------
|
94 | 85 | # Right
|
|
102 | 93 | # Plot an envelope based on the bounds ("+b")
|
103 | 94 | fig.plot(data=df_bound, close="+b+p0.5p,gray30,dashed", pen="1p,gray30")
|
104 | 95 |
|
105 |
| -# Plot the data points on top |
106 | 96 | fig.plot(data=df_bound, style="c0.2c", pen="1p,gray30", fill="darkgray")
|
107 | 97 |
|
108 | 98 | fig.show()
|
0 commit comments