@@ -621,7 +621,7 @@ def image(self, imagefile, **kwargs):
621
621
@fmt_docstring
622
622
@use_alias (R = "region" , J = "projection" , D = "position" , F = "box" )
623
623
@kwargs_to_strings (R = "sequence" )
624
- def legend (self , spec = None , ** kwargs ):
624
+ def legend (self , spec = None , position = "JTR+jTR+o0.2c" , box = "+gwhite+p1p" , ** kwargs ):
625
625
"""
626
626
Plot legends on maps.
627
627
@@ -644,13 +644,23 @@ def legend(self, spec=None, **kwargs):
644
644
{R}
645
645
position (D) : str
646
646
``'[g|j|J|n|x]refpoint+wwidth[/height][+jjustify][+lspacing][+odx[/dy]]'``
647
- Defines the reference point on the map for the legend.
647
+ Defines the reference point on the map for the legend. By default, uses
648
+ 'JTR+jTR+o0.2c' which places the legend at the top-right corner inside
649
+ the map frame, with a 0.2 cm offset.
648
650
box (F) : bool or str
649
651
``'[+cclearances][+gfill][+i[[gap/]pen]][+p[pen]][+r[radius]][+s[[dx/dy/][shade]]]'``
650
652
Without further options, draws a rectangular border around the
651
- legend using **MAP_FRAME_PEN**.
653
+ legend using **MAP_FRAME_PEN**. By default, uses '+gwhite+p1p' which draws
654
+ a box around the legend using a 1 point black pen and adds a white background.
652
655
"""
653
656
kwargs = self ._preprocess (** kwargs )
657
+
658
+ if "D" not in kwargs :
659
+ kwargs ["D" ] = position
660
+
661
+ if "F" not in kwargs :
662
+ kwargs ["F" ] = box
663
+
654
664
with Session () as lib :
655
665
if spec is None :
656
666
specfile = ""
0 commit comments