{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Hiding all node markers\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "By default, markers of root nodes of subtrees are visible. Visibility is controlled by marker\nsizes. All node markers can be hidden by setting all marker sizes to zero.\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 make_components\n\nX = [[0.0], [1.0], [3.0], [6.0]]\nZ = scipy.cluster.hierarchy.linkage(X)\n\nT = scipy.cluster.hierarchy.fcluster(Z, 1.5, criterion=\"distance\")\nL, _ = scipy.cluster.hierarchy.leaders(Z, T)\n\nnode_trace, link_traces, x_axis, y_axis = make_components(Z, subtrees=L)\nnode_trace.update(marker={\"size\": [0]*len(node_trace.marker.size)})\n\nfig = go.Figure()\nfig.add_traces(list(link_traces.values()))\nfig.add_trace(node_trace)\nfig.update_xaxes(x_axis)\nfig.update_yaxes(y_axis)\npio.show(fig)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Alternatively, if the :func:`~pdendro.attach_dendrogram` function is used, marker sizes must be\nmodified later.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from pdendro import attach_dendrogram\n\nfig = go.Figure()\nattach_dendrogram(fig, Z, subtrees=L)\n\nnode_trace = fig.data[-1]\nnode_trace.update(marker={\"size\": [0]*len(node_trace.marker.size)})\n\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 }