causalnex.plots.color_gradient_string

causalnex.plots.color_gradient_string(from_color, to_color, steps)[source]

Create a pygraphgiz compatible color gradient string.

This string can be used when setting colors for nodes, edges, and graph attributes.

Example:

node_attributes = {
   "color": color_gradient_string(
       from_color="#000000", to_color="#FFFFFF", steps=30
   )
}
Parameters:
  • from_color (str) – rgb(a) string of color to start gradient from
  • to_color (str) – rgb(a) string of color to end gradient at
  • steps (int) – number of steps in the gradient string. steps=1 produces from_color:to_color
  • any intermediary steps (without) –
Return type:

str

Returns:

a pygraphviz color gradient string