eafpy.colour module#
- eafpy.colour.RGBA_arr_to_string(rgba_arr)[source]#
RGBA array to RGBA string
Convert a matrix of RGBA values to list of rgba strings. If the input array has only one row, then return single string
- Parameters:
rgba_arr (
numpy array (n
,4)
) – Numpy array with n rows and 4 columns, where each row represents a different colour and each column is a float representing one of RGBA If n=1, then return a single string instead of a list- Returns:
A list of rgba(w,x,y,z) strings compatible with a plotly colorscale
- Return type:
list
- eafpy.colour.discrete_colour_gradient(colour_a, colour_b, num_steps)[source]#
Create colour gradient list for use in plotly colorscales Linearly interpolates between two colours using a define amount of steps
- Parameters:
color_a (
string
) – The names of standard CSS colours to create a gradientcolor_b (
string
) – The names of standard CSS colours to create a gradientsteps (
integer
) – Number of steps between between the starting and ending colour. Also the size of the list returned
- Returns:
A list of RGBA string values compatible with plotly colorscales
- Return type:
list
- eafpy.colour.discrete_opacity_gradient(colour, num_steps, start_opacity=0.0, end_opacity=1.0)[source]#
Create opacity gradient colour list for use in plotly colorscales
Linearly interpolates between starting and ending opacity
- Parameters:
color (
string
) – The name of a standard CSS coloursteps (
integer
) – Number of steps between the start and end opacity. Also the size of the list returnedstart_opacity (
floats
) – Choose what the starting and ending values of opacity are for the list of colours (between 0 and 1)end_opacity (
floats
) – Choose what the starting and ending values of opacity are for the list of colours (between 0 and 1)
- Returns:
list
– A list of RGBA string values compatible with plotly colorscales, interpolating opacity between two values# TODO FIXME add examples
ofthis in the styling tutorial
- eafpy.colour.parse_colour_to_nparray(colour, strings=False)[source]#
parse a single colour argument to a (1,4) numpy array representing its RGBA values This can be used to manipulate the values before converting it back to RGBA string using
RGBA_arr_to_string()
- Parameters:
colour (
Named CSS colour
,RGBA string
or8 character hex RGBA integer
) –- A colour argument can be one of the following:
Named CSS colour string: “red” or “hotpink” RGBA string: “rgba(0.2, 0.5, 0.1, 0.5)” 8 character hex RGBA integer: 0x1234abcde
strings (
boolean
) – If strings=True then the argument will return a list of ‘rgba(w,x,y,z)’ strings instead of a numpy array
- Returns:
A (1,4) numpy array where each index represents one of the red, green, blue, alpha values (from 0-1)
- Return type:
numpy array (1,4)