@@ -967,12 +967,9 @@ def show(
967967 e.g. ``{"location": "lower right", "color": "white", "length_fraction": 0.25}``.
968968 See the matplotlib-scalebar documentation for the full list of options.
969969 legend_params : dict[str, Any] | None
970- Bundled legend options. Mirrors ``colorbar_params`` / ``scalebar_params``. Accepted keys:
971- ``location`` (canonical, alias ``loc`` accepted to match
972- :class:`matplotlib.legend.Legend`), ``fontsize``, ``fontweight``, ``fontoutline``,
973- ``na_in_legend``. When a key is set both as a flat kwarg (e.g. ``legend_fontsize=12``)
974- and inside this dict, the dict value wins. Unknown keys raise ``ValueError`` to surface
975- typos early.
970+ Bundled legend options; overrides the matching ``legend_*`` flat kwargs. Accepted keys:
971+ ``location`` (or ``loc``), ``fontsize``, ``fontweight``, ``fontoutline``,
972+ ``na_in_legend``. Unknown keys raise ``ValueError``.
976973
977974 Returns
978975 -------
@@ -1140,15 +1137,10 @@ def show(
11401137 scalebar_units = scalebar_units ,
11411138 scalebar_kwargs = scalebar_params ,
11421139 )
1143- # Merge dict-form legend_params over the flat legend_* kwargs (dict wins). Unknown keys
1144- # have already been rejected by _validate_show_parameters; treat the dict as authoritative.
1145- # Note: matplotlib.legend.Legend uses `loc`, while Figure.colorbar and matplotlib_scalebar
1146- # use `location`. We accept both spellings so legend_params reads consistently with
1147- # colorbar_params / scalebar_params; `location` is the canonical name and wins if both are
1148- # passed.
11491140 if legend_params :
11501141 legend_fontsize = legend_params .get ("fontsize" , legend_fontsize )
11511142 legend_fontweight = legend_params .get ("fontweight" , legend_fontweight )
1143+ # `loc` is matplotlib.Legend's native key; `location` aligns with colorbar/scalebar.
11521144 legend_loc = legend_params .get ("location" , legend_params .get ("loc" , legend_loc ))
11531145 legend_fontoutline = legend_params .get ("fontoutline" , legend_fontoutline )
11541146 na_in_legend = legend_params .get ("na_in_legend" , na_in_legend )
0 commit comments