Skip to content

Commit ae92da2

Browse files
authored
Add auto-legend feature to grdcontour and contour (#568)
Add label argument to Figure.grdcontour() and Figure.contour().
1 parent a95dd6f commit ae92da2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pygmt/base_plotting.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ def colorbar(self, **kwargs):
226226
S="resample",
227227
U="timestamp",
228228
W="pen",
229+
l="label",
229230
)
230231
@kwargs_to_strings(R="sequence", L="sequence", A="sequence_plus")
231232
def grdcontour(self, grid, **kwargs):
@@ -275,6 +276,13 @@ def grdcontour(self, grid, **kwargs):
275276
{G}
276277
{U}
277278
{W}
279+
label : str
280+
Add a legend entry for the contour being plotted. Normally, the
281+
annotated contour is selected for the legend. You can select the
282+
regular contour instead, or both of them, by considering the label
283+
to be of the format [*annotcontlabel*][/*contlabel*]. If either
284+
label contains a slash (/) character then use ``|`` as the
285+
separator for the two labels instead.
278286
"""
279287
kwargs = self._preprocess(**kwargs)
280288
kind = data_kind(grid, None, None)
@@ -568,6 +576,7 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs):
568576
W="pen",
569577
L="triangular_mesh_pen",
570578
i="columns",
579+
l="label",
571580
C="levels",
572581
)
573582
@kwargs_to_strings(R="sequence", i="sequence_comma")
@@ -619,6 +628,13 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
619628
skip : bool or str
620629
Skip input points outside region ``'[p|t]'``
621630
{W}
631+
label : str
632+
Add a legend entry for the contour being plotted. Normally, the
633+
annotated contour is selected for the legend. You can select the
634+
regular contour instead, or both of them, by considering the label
635+
to be of the format [*annotcontlabel*][/*contlabel*]. If either
636+
label contains a slash (/) character then use ``|`` as the
637+
separator for the two labels instead.
622638
623639
"""
624640
kwargs = self._preprocess(**kwargs)

0 commit comments

Comments
 (0)