Python from color name to RGB

前端 未结 2 1913
悲&欢浪女
悲&欢浪女 2021-01-17 14:28

If I have a function which takes color as an input to be edited first (by RGB numbers), and then used in matplotlib.pyplot. How can I

相关标签:
2条回答
  • 2021-01-17 15:00

    You can use with matplotlib.colors

    from matplotlib import colors
    
    print(colors.to_rgba('blue'))
    

    Result:

    (0.0, 0.0, 1.0, 1.0)
    
    0 讨论(0)
  • 2021-01-17 15:00

    Found the solution, by

    from matplotlib import colors
    orange_rgb = colors.hex2color(colors.cnames['orange'])
    
    0 讨论(0)
提交回复
热议问题