subrela.plot.bokeh.draw_node_marker function

subrela.plot.bokeh.draw_node_marker(fig, node_data, orientation='vertical', kws=None)[source]

Draw markers of nodes.

Parameters
  • fig (bokeh.plotting.figure.Figure) – Figure on which markers are drawn.

  • node_data (pandas.DataFrame) – Data of nodes returned by subrela.plot.get_dendrogram_data function.

  • orientation ({'vertical', 'horizontal'}, optional) – Orientation of a tree. If 'vertical', the height direction of a tree corresponds to the y axis. If 'horizontal', it corresponds to the x axis.

  • kws (dict or None, optional) – Keyword arguments passed to bokeh.plotting.figure.Figure.scatter method.

Returns

scatter (bokeh.models.renderers.GlyphRenderer) – Renderer for markers.

Raises

ValueError – If kws contains keys 'x', 'y', and 'source'.

Notes

The default value for kws['color'] is None.

Examples

import numpy
import bokeh.plotting
import bokeh.io
from subrela.clustering import get_clusters
from subrela.plot import get_dendrogram_data
from subrela.plot.bokeh import draw_dendrogram, draw_node_marker

X = numpy.array([[0, -5, -5, 6, 6], [0, -1, 1, -2, 2]])

Z = get_clusters(X)
leaf_data, node_data, tree_data, cut_data = get_dendrogram_data(Z)

fig = bokeh.plotting.Figure(plot_width=300, plot_height=300)
draw_dendrogram(fig, leaf_data, tree_data, cut_data)
draw_node_marker(fig, node_data, kws={'color': 'red'})
bokeh.io.show(fig)