ragraph.plot.components.legend#

Re-usable legend plot components.

Module Contents#

Classes#

Legend

Legend component.

Functions#

get_categorical_legend_traces(...)

Create categorical legend traces.

get_swatchtraces() → List[plotly.graph_objs.Scatter])

Swatch bar of color map.

get_numerical_legend_traces(...)

Get traces for a numerical legend,

get_legend_categories(→ List[str])

Get the number of categories to be included in the legend.

class ragraph.plot.components.legend.Legend(edges: List[ragraph.edge.Edge], style: ragraph.plot.generic.Style = Style())#

Bases: ragraph.plot.generic.Component

Legend component.

Parameters:
  • edges – List displayed edges.

  • style – Plot style mapping.

ragraph.plot.components.legend.get_categorical_legend_traces(categories: List[str], style: ragraph.plot.generic.Style = Style()) List[plotly.graph_objs.Scatter]#

Create categorical legend traces.

Parameters:
  • categories – List of categories.

  • style – Plot style mapping.

Returns:

List of traces.

ragraph.plot.components.legend.get_swatchtraces(idx: int, name: str, colors: List[str], min_value: float, max_value: float, style: ragraph.plot.generic.Style = Style()) List[plotly.graph_objs.Scatter]#

Swatch bar of color map.

Parameters:
  • idx – Number of the swatch that must be created.

  • name – name of the swatch trace.

  • colors – List of colors to be added to the swatch trace

  • min_value – Minimum value of the weight related to the color map.

  • max_value – Maximmum value of the weight related to the color map.

  • style – Style object.

Returns:

List of go.Scatter traces.

ragraph.plot.components.legend.get_numerical_legend_traces(edges: List[ragraph.edge.Edge], style: ragraph.plot.generic.Style = Style()) List[plotly.graph_objs.Scatter]#

Get traces for a numerical legend,

Parameters:
  • edges – List of edges that are displayed.

  • style – Style object.

Returns:

List of traces.

ragraph.plot.components.legend.get_legend_categories(edges: List[ragraph.edge.Edge], display: str) List[str]#

Get the number of categories to be included in the legend.

Parameters:
  • edges – The list of edges that are being displayed.

  • display – The selected display mode.

Returns:

list of categories.