{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ " import ipycytoscape" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data = {'nodes': [\n", " { 'data': { 'label': 'top left' }, 'classes': 'top-left' },\n", " { 'data': { 'label': 'top center' }, 'classes': 'top-center' },\n", " { 'data': { 'label': 'top right' }, 'classes': 'top-right' },\n", "\n", " { 'data': { 'label': 'center left' }, 'classes': 'center-left' },\n", " { 'data': { 'label': 'center center' }, 'classes': 'center-center' },\n", " { 'data': { 'label': 'center right' }, 'classes': 'center-right' },\n", "\n", " { 'data': { 'label': 'bottom left' }, 'classes': 'bottom-left' },\n", " { 'data': { 'label': 'bottom center' }, 'classes': 'bottom-center' },\n", " { 'data': { 'label': 'bottom right' }, 'classes': 'bottom-right' },\n", "\n", " { 'data': { 'label': 'multiline manual\\nfoo\\nbar\\nbaz' }, 'classes': 'multiline-manual' },\n", " { 'data': { 'label': 'multiline auto foo bar baz' }, 'classes': 'multiline-auto' },\n", " { 'data': { 'label': 'outline' }, 'classes': 'outline' },\n", "\n", " { 'data': { 'id': 'ar-src' } },\n", " { 'data': { 'id': 'ar-tgt' } },\n", " { 'data': { 'source': 'ar-src', 'target': 'ar-tgt', 'label': 'autorotate (move my nodes)' }, 'classes': 'autorotate' },\n", " { 'data': { 'label': 'background' }, 'classes': 'background' }\n", "]}" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cytoscapeobj = ipycytoscape.CytoscapeWidget(elements=data)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cytoscapeobj.set_style([\n", " {\n", " 'selector': 'node[label]',\n", " 'style': {\n", " 'font-family': 'helvetica',\n", " 'font-size': '20px',\n", " }\n", " },\n", " {\n", " 'selector': 'node[label]',\n", " 'style': {\n", " 'label': 'data(label)'\n", " }\n", " },\n", "\n", " {\n", " 'selector': 'edge[label]',\n", " 'style': {\n", " 'label': 'data(label)',\n", " 'width': 3\n", " }\n", " },\n", "\n", " {\n", " 'selector': '.top-left',\n", " 'style': {\n", " 'text-valign': 'top',\n", " 'text-halign': 'left'\n", " }\n", " },\n", "\n", " {\n", " 'selector': '.top-center',\n", " 'style': {\n", " 'text-valign': 'top',\n", " 'text-halign': 'center'\n", " }\n", " },\n", "\n", " {\n", " 'selector': '.top-right',\n", " 'style': {\n", " 'text-valign': 'top',\n", " 'text-halign': 'right'\n", " }\n", " },\n", "\n", " {\n", " 'selector': '.center-left',\n", " 'style': {\n", " 'text-valign': 'center',\n", " 'text-halign': 'left'\n", " }\n", " },\n", "\n", " {\n", " 'selector': '.center-center',\n", " 'style': {\n", " 'text-valign': 'center',\n", " 'text-halign': 'center'\n", " }\n", " },\n", "\n", " {\n", " 'selector': '.center-right',\n", " 'style': {\n", " 'text-valign': 'center',\n", " 'text-halign': 'right'\n", " }\n", " },\n", "\n", " {\n", " 'selector': '.bottom-left',\n", " 'style': {\n", " 'text-valign': 'bottom',\n", " 'text-halign': 'left'\n", " }\n", " },\n", "\n", " {\n", " 'selector': '.bottom-center',\n", " 'style': {\n", " 'text-valign': 'bottom',\n", " 'text-halign': 'center'\n", " }\n", " },\n", "\n", " {\n", " 'selector': '.bottom-right',\n", " 'style': {\n", " 'text-valign': 'bottom',\n", " 'text-halign': 'right'\n", " }\n", " },\n", "\n", " {\n", " 'selector': '.multiline-manual',\n", " 'style': {\n", " 'text-wrap': 'wrap'\n", " }\n", " },\n", "\n", " {\n", " 'selector': '.multiline-auto',\n", " 'style': {\n", " 'text-wrap': 'wrap',\n", " 'text-max-width': 80\n", " }\n", " },\n", "\n", " {\n", " 'selector': '.autorotate',\n", " 'style': {\n", " 'edge-text-rotation': 'autorotate'\n", " }\n", " },\n", "\n", " {\n", " 'selector': '.background',\n", " 'style': {\n", " 'text-background-opacity': 1,\n", " 'color': '#fff',\n", " 'text-background-color': '#888',\n", " 'text-background-shape': 'roundrectangle',\n", " 'text-border-color': '#000',\n", " 'text-border-width': 1,\n", " 'text-border-opacity': 1\n", " }\n", " },\n", "\n", " {\n", " 'selector': '.outline',\n", " 'style': {\n", " 'color': '#fff',\n", " 'text-outline-color': '#888',\n", " 'text-outline-width': 3\n", " }\n", " }\n", "])" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "cytoscapeobj.set_layout(name='grid')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cytoscapeobj" ] } ], "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 }