|
23 | 23 |
|
24 | 24 |
|
25 | 25 | # %% |
26 | | -# Fill the area between the two curves using the ``fill_between`` parameter. |
| 26 | +# Fill the areas between the two curves using the ``fill_between`` parameter. |
| 27 | +# Use the ``fill`` parameter and the modifier **+g** for ``fill_between`` to |
| 28 | +# set different fills for areas with y1 > y2 and y2 < y1, respectively. Use |
| 29 | +# the ``label`` parameter and the modifier **+l** for ``fill_between`` to |
| 30 | +# set the corresponding legend entries. |
27 | 31 |
|
28 | 32 | fig = gmt.Figure() |
29 | 33 | fig.basemap(region=[-10, 10, -5, 5], projection="X15c/5c", frame=True) |
30 | 34 |
|
31 | 35 | fig.plot( |
32 | 36 | data=data_df, |
33 | 37 | fill="orange", |
34 | | - fill_between="c+gsteelblue+lshort < long", |
35 | 38 | label="short > long", |
| 39 | + fill_between="c+gsteelblue+lshort < long", |
36 | 40 | ) |
37 | 41 |
|
38 | 42 | fig.legend() |
|
41 | 45 |
|
42 | 46 |
|
43 | 47 | # %% |
44 | | -# Additionally we can draw the curves. |
| 48 | +# Additionally to filling the areas, we can draw the curves. Use the ``pen`` |
| 49 | +# parameter and the modifier **+p** for ``fill_between`` to set different |
| 50 | +# lines for the two curves y1 and y2, respectively. |
45 | 51 |
|
46 | | -# Set up new Figure instance |
47 | 52 | fig = gmt.Figure() |
48 | 53 | fig.basemap(region=[-10, 10, -5, 5], projection="X15c/5c", frame=True) |
49 | 54 |
|
|
58 | 63 |
|
59 | 64 |
|
60 | 65 | # %% |
61 | | -# Compare to a horizontal line. |
| 66 | +# To compare a curve y1 to a horizontal line, append **+y** to ``fill_between`` |
| 67 | +# and give the desired y-level. |
62 | 68 |
|
63 | | -# Set up new Figure instance |
64 | 69 | fig = gmt.Figure() |
65 | 70 | fig.basemap(region=[-10, 10, -5, 5], projection="X15c/5c", frame=True) |
66 | 71 |
|
67 | 72 | fig.plot( |
68 | 73 | data=data_df[["x", "y1"]], |
69 | 74 | fill="p8", |
70 | 75 | pen="1p,black,solid", |
| 76 | + # Define a horizontal line at y=0.42 |
71 | 77 | fill_between="c+gp17+p1p,black,dashed+y0.42", |
72 | 78 | ) |
73 | 79 |
|
|
0 commit comments