From 2d392cdefe78a7e7c7e5f088c82c3828abe10bcc Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Mon, 13 Sep 2021 18:11:53 +0200 Subject: [PATCH] Backport PR #20913: [Doc] colors.to_hex input & output --- lib/matplotlib/colors.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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: