I've created a plot showing earthquake data; plotted so that the symbols scale with magnitude. Is there a way to add whitespace between the legend entries in PyGMT so that the symbols are not overlapping?
Can't find anything in the online documentation. Is it possible to add an option to the FONT_ parameters?
How do you create your legend, i.e, from an input file or via the label
parameter?
In general, sharing a code example makes it easier for people to help you (:
(I) input file
Please have a look at the legend code G, see https://docs.generic-mapping-tools.org/latest/legend.html#legend-codes.
(II) label
parameter
Here is a basic code example showing how to add vertical space between the single legend entries (append +G to the label
parameter) as well as to add space between the box and the legend entries (use C of the pygmt.Figure.legend
method).
import pygmt
size = 5
fig = pygmt.Figure()
fig.basemap(
region=[-size, size, -size, size],
projection="X" + str(size*2) + "c",
frame=True,
)
fig.plot(x=0, y=0, style="c1c", label="Circle")
fig.plot(x=0, y=-2, style="s1c", label="Square")
fig.legend()
fig.shift_origin(xshift="w+1c")
fig.basemap(
region=[-size, size, -size, size],
projection="X" + str(size*2) + "c",
frame=True,
)
fig.plot(x=0, y=0, style="c1c", label="Circle")
# https://docs.generic-mapping-tools.org/latest/gmt.html#l-full
fig.plot(x=0, y=-2, style="s1c", label="Square+G1c")
# https://docs.generic-mapping-tools.org/latest/legend.html#c
fig.legend(C="0.1c/0.5c") # x / y directions
fig.show()