diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index 281b23eed89c..25d56f77618f 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -390,8 +390,17 @@ def to_hex(c, keep_alpha=False): """ Convert *c* to a hex color. - Uses the ``#rrggbb`` format if *keep_alpha* is False (the default), - ``#rrggbbaa`` otherwise. + Parameters + ---------- + c : :doc:`color ` or `numpy.ma.masked` + + keep_alpha: bool, default: False + If False, use the ``#rrggbb`` format, otherwise use ``#rrggbbaa``. + + Returns + ------- + str + ``#rrggbb`` or ``#rrggbbaa`` hex color string """ c = to_rgba(c) if not keep_alpha: