Skip to content

matplotlib.colors rgb2hex is not the right inverse of hex2color #18574

@SebastianoF

Description

@SebastianoF
>>> matplotlib.__version__
'3.3.2'
>>> from matplotlib.colors import rgb2hex, hex2color
>>> rgb_color = (0.5, 0.5, 0.9)
>>> hex2color(rgb2hex(rgb_color))
(0.5019607843137255, 0.5019607843137255, 0.9019607843137255)

It should return (0.5, 0.5, 0.9).
As it seems the additive factor it is always the same, it should be a matter of subtracting 0.0019607843137255 from the three channels.

Thanks!


P.S. the inverse composition works as expected:

>>> rgb2hex(hex2color( '#808080'))
'#808080'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy