Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

convert hex rgb to matplotlib color

hex_color = '3366CC'

# from 0-255 integer format
up_to_255_rgb = tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
#output: (51, 102, 204)

# from 0-1 float format
up_to_1_rgb = tuple(int(hex_color[i:i+2], 16)/255 for i in (0, 2, 4))
#output: (0.2, 0.4, 0.8)
Comment

convert hex rgb to matplotlib color

hex_color = '3366CC'

# from 0-255 integer format
up_to_255_rgb = tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
#output: (51, 102, 204)

# from 0-1 float format
up_to_1_rgb = tuple(int(hex_color[i:i+2], 16)/255 for i in (0, 2, 4))
#output: (0.2, 0.4, 0.8)
Comment

PREVIOUS NEXT
Code Example
Python :: map function to change type of element in python 
Python :: python strip() 
Python :: pandas get rows which are NOT in other dataframe 
Python :: python re.sub() 
Python :: python list with several same values 
Python :: standard noramlization 
Python :: Python Switch case statement by Dictionary Mapping 
Python :: python index for all matches 
Python :: how to overlap two barplots in seaborn 
Python :: empty list check in python 
Python :: prime numbers upto n in python 
Python :: Python DateTime Class Syntax 
Python :: python capture stdout 
Python :: double underscore methods python 
Python :: drop row pandas column value not a number 
Python :: upload file setup django url 
Python :: how to turn a string into an integer python 
Python :: what does the .item() do in python 
Python :: binary search in python 
Python :: precision accuracy recall python example 
Python :: how to convert string to int in python 
Python :: pandas filter 
Python :: shape of variable python 
Python :: pandas save dataframe with list 
Python :: python multidimensional dictionary 
Python :: How to split a string into a dictionary in Python 
Python :: python strings 
Python :: sort dataframe by function 
Python :: python describe 
Python :: format datetime python pandas 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =