{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ipycytoscape\n", "import networkx as nx\n", "import matplotlib.pyplot as plt\n", "\n", "cytoscapeobj = ipycytoscape.CytoscapeWidget()\n", "cytoscapeobj" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Testing sync between python and js\n", "\n", "cytoscapeobj.add_node(2, \"potato\")\n", "cytoscapeobj.add_node(1, \"potato\")\n", "cytoscapeobj.add_node(4, \"potato\")\n", "cytoscapeobj.add_node(6, \"potato\")\n", "cytoscapeobj.add_node(8, \"potato\")\n", "cytoscapeobj.add_node(10, \"potato\")\n", "cytoscapeobj.add_node(12, \"potato\")\n", "cytoscapeobj.add_node(14, \"potato\")\n", "cytoscapeobj.add_edge(2, 1)\n", "cytoscapeobj.add_edge(2, 4)\n", "cytoscapeobj.add_edge(2, 6)\n", "cytoscapeobj.add_edge(2, 8)\n", "cytoscapeobj.add_edge(2, 10)\n", "cytoscapeobj.add_edge(2, 12)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Testing zoom method\n", "\n", "cytoscapeobj.zoom = 1" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cytoscapeobj.rendered_position = {'x': 1200, 'y': 10}" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cytoscapeobj.rendered_position" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Changing the zoom in python\n", "cytoscapeobj.zoom = 2\n", "\n", "# Observe the expected change in the frontend\n", "cytoscapeobj.zoom" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.8.1" } }, "nbformat": 4, "nbformat_minor": 4 }