{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# PyVis Test" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import openalea\n", "from openalea.mtg import *\n", "from openalea.mtg.data import data_dir as data\n", "from openalea.widgets.mtg import plot" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "198\n" ] }, { "data": { "text/plain": [ "3" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g = MTG(data/'boutdenoylum2.mtg')\n", "print(g.nb_vertices(scale=g.max_scale()))\n", "g.max_scale()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "MTG : nb_vertices=263, nb_scales=4\n", "/P1\t\t\t(id=1)\t\t\t\t\t\t\t\t\t\t\t\n", "^/A1\t\t\t(id=2)\t\t\t\t\t\t\t\t\t\t\t\n", "^/S1\t\t\t(id=3)\t\t\t\t\t\t\t\t\t\t\t\n", "\t+A1\t\t\t(id=4)\t\t\t\t\t\t\t\t\t\t\n", "\t^/S1\t\t\t(id=5)\t\t\t\t\t\t\t\t\t\t\n", "^\n", " " ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot(g)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "root = next(g.roots_iter(scale=g.max_scale()))\n", "selection = g.Trunk(root)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "mtg.html\n" ] }, { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot(g, selection=selection)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "mtg.html\n" ] }, { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "max_scale = g.max_scale()\n", "s = [vid for vid in g.vertices(scale=max_scale) if g.is_leaf(vid)]\n", "s = [next(g.component_roots_at_scale_iter(cid, scale=max_scale)) for cid in g.vertices(scale=max_scale-1)]\n", "root_id = 69\n", "s = g.Descendants(root_id)\n", "\n", "plot(g, selection=s)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.12.3" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": {}, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 4 }