{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Inspecting node\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Information about a node is displayed in its tooltip. There are three items: ``id``, ``distance``,\nand ``size``.\n\nThe ``id`` is the :term:`node ID`. In the following code, the ``id`` of a leaf node corresponding\nto ``X[i]`` is ``i`` and that of a branch node corresponding to ``Z[i]`` is ``i+n``.\n\nThe ``distance`` is the distance between child nodes. It is zero for leaf nodes. In the following\ncode, the ``distance`` of a branch node corresponding to ``Z[i]`` is its y-coordinate, or\n``Z[i, 2]``.\n\nThe ``size`` is the number of descendant leaf nodes. It is one for leaf nodes. In the following\ncode, the ``size`` of a branch node corresponding to ``Z[i]`` is ``Z[i, 3]``.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import plotly.graph_objects as go\nimport plotly.io as pio\nimport scipy\n\nfrom pdendro import attach_dendrogram\n\nX = [[0.0], [1.0], [3.0], [6.0]]\n\nZ = scipy.cluster.hierarchy.linkage(X)\n\nfig = go.Figure()\nattach_dendrogram(fig, Z)\npio.show(fig)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.14.4" } }, "nbformat": 4, "nbformat_minor": 0 }