|
44 | 44 |
|
45 | 45 |
|
46 | 46 | # %% |
47 | | -# Adjust the position |
48 | | -# ------------------- |
| 47 | +# Adjust position and line spacing |
| 48 | +# -------------------------------- |
49 | 49 | # |
50 | 50 | # Use the ``position`` parameter to adjust the position of the legend. Note, no box is |
51 | | -# drawn by default if ``position`` is used. |
| 51 | +# drawn by default if ``position`` is used |
52 | 52 |
|
53 | 53 | fig = pygmt.Figure() |
54 | | -fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame=True) |
| 54 | +fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame="rltb") |
55 | 55 |
|
56 | 56 | fig.plot(x=0, y=0, style="c0.25c", fill="orange", label="orange circle") |
57 | 57 | fig.plot(x=1, y=0, style="t0.3c", fill="pink", pen="black", label="pink triangle") |
|
61 | 61 | # and 0.2 centimeters in the x- and y-directions, respectively. |
62 | 62 | fig.legend(position=Position("TL", offset=(0.3, 0.2))) |
63 | 63 |
|
| 64 | +fig.shift_origin(xshift="w+1c") |
| 65 | +fig.basemap(region=[-5, 5, -5, 5], projection="X5c", frame="rltb") |
| 66 | + |
| 67 | +fig.plot(x=0, y=0, style="c0.25c", fill="orange", label="orange circle") |
| 68 | +fig.plot(x=1, y=0, style="t0.3c", fill="pink", pen="black", label="pink triangle") |
| 69 | +fig.plot(x=[-3, 3], y=[-2, -2], pen="darkred", label="darkred line") |
| 70 | + |
| 71 | +# Use a line spacing factor of 1.5 |
| 72 | +fig.legend(position=Position("TL", offset=(0.3, 0.2)), line_spacing=1.5) |
| 73 | + |
64 | 74 | fig.show() |
65 | 75 |
|
66 | 76 |
|
67 | 77 | # %% |
68 | 78 | # Add a box |
69 | 79 | # --------- |
| 80 | + |
70 | 81 | # Use the ``box`` parameter for adjusting the box around the legend. |
71 | 82 |
|
72 | 83 | fig = pygmt.Figure() |
|
0 commit comments