Holoviews-Bokeh#
This notebook discusses how to use the HivePlot class with the holoviews-bokeh visualization back end.
Note: the holoviews-bokeh viz back end requires that Hiveplotlib be installed with extra packages, which can be done by running:
pip install hiveplotlib[holoviews]
[1]:
from hiveplotlib.datasets import example_hive_plot
Change Plotting Kwargs For Nodes, Edges, and Axes#
By default, Hiveplotlib viz keeps all colors black, with standardized sizes that should cover most users’ needs:
[2]:
hp = example_hive_plot(backend="holoviews-bokeh")
fig = hp.plot()
fig.opts(title="Base Holoviews-Bokeh Hive Plot Viz")
fig
[2]:
All of these defaults, however, can be modified. Below, we modify every color and size to serve as a reference for how to change these defaults with the holoviews-bokeh back end:
[3]:
fig = hp.plot(
# node kwarg changes
node_kwargs={
"size": 15,
"fill_color": None, # empty node fill color
"line_color": "blue",
"line_width": 2,
"alpha": 0.4,
},
# axes label kwarg changes
axes_labels_fontsize=32,
text_kwargs={
"text_color": "purple",
"text_font_style": "bold italic",
},
# axes kwarg changes
axes_kwargs={
"line_width": 10,
"color": "yellow",
"line_alpha": 0.9,
},
# edge kwarg changes
color="red",
line_width=3,
alpha=0.1,
)
fig
[3]:
Plotting Node Metadata#
Users may want to visualize nodes with respect to node metadata. For more on visualizing node metadata, see the Visualizing Node Metadata page.
Below, we demonstrate modifying nodes according to metadata for both size and color.
[4]:
hp = example_hive_plot(
repeat_axes=True,
backend="holoviews-bokeh",
)
# scale the low variable to make more useful sizes in viz
hp.nodes.data["size"] = hp.nodes.data["low"].to_numpy() + 5
# propagate extra node data changes through to data on axes
hp.update_partition_data()
node_kwargs = {
"fill_color": "low", # reference to "low" var in node data
"size": "size", # reference to "size" var in node data
"line_color": "black",
"colorbar": True,
"clim": (0, 10), # fixed color range consistent between each axis
"cmap": "magma",
"clabel": "Node Variable 'low'",
}
hp.update_node_viz_kwargs(**node_kwargs)
# when including color bar, make wider to maintain 1:1 aspect
fig = hp.plot(
overlay_kwargs={"width": 650, "height": 400},
)
fig
[4]:
Plotting Edge Metadata#
Users may want to visualize edges with respect to edge metadata. For more on visualizing edge metadata, see the Visualizing Edge Metadata page.
Below, we demonstrate modifying edges according to metadata for both line width and color.
[5]:
hp = example_hive_plot(
repeat_axes=True,
backend="holoviews-bokeh",
)
# scale the low variable to make more useful line widths in viz
hp.edges.data["linewidth"] = hp.edges.data["low"] / 3
edge_kwargs = {
"color": "low", # reference to "low" var in edge data
"line_width": "linewidth", # reference to "linewidth" variable in edge data
"colorbar": True,
"clim": (0, 10), # fixed color range consistent between each axis
"cmap": "cividis",
"clabel": "Edge Variable 'low'",
}
hp.update_edge_plotting_keyword_arguments(**edge_kwargs)
# when including color bar, make wider to maintain 1:1 aspect
fig = hp.plot(
overlay_kwargs={"width": 650, "height": 400},
)
fig
[5]:
Hover Information#
We encourage users to review the high-level overview on adding hover information on the Hover Information page first.
Below, we summarize the unique behavior with the holoviews-bokeh back end when adding or modifying hover information.
Axis Hover Information#
With the holoviews-bokeh back end, axis hover information shows up when moving your mouse along the axis:
[6]:
hp = example_hive_plot(backend="holoviews-bokeh")
fig = hp.plot(hover="axes")
fig
[6]:
Axis-Specific Metadata#
When a subset of axes has added metadata not available on other axes, all axes will show that metadata variable, but the axes without the variable will display the value N/A.
Below, we demonstrate this by adding a new metadata variable to only axis A:
[7]:
hp = example_hive_plot(backend="holoviews-bokeh")
# add metadata value to just axis A
hp.axes["A"].add_metadata({"Special Axis Data": "My Special 'A' Value"})
fig = hp.plot(hover="axes")
fig
[7]: