Skip to main content

No project description provided

Project description

Cosmograph Jupyter Widget

This Jupyter widget integrates the @cosmograph/cosmograph library, enabling interactive visualizations of complex graphs directly within Jupyter notebooks. Built using the Anywidget framework.

Installation

To install the Cosmograph Jupyter widget, run the following command:

pip install cosmograph_widget

PyPI Version

Basic Example

Here is a simple example of how to use the Cosmograph Jupyter widget:

from cosmograph_widget import Cosmograph
import pandas as pd

# Define the points of the graph
points = pd.DataFrame([
  { 'id': '1', 'color': '#88C6FF' },
  { 'id': '2', 'color': '#FF99D2' },
  { 'id': '3', 'color': '#E3116C' },
])

# Define the links of the graph
links = pd.DataFrame([
  { 'source': '1', 'target': '2' },
  { 'source': '1', 'target': '3' },
  { 'source': '2', 'target': '3' },
])

# Initialize and display the Cosmograph widget
Cosmograph(points=points, links=links,
   point_id_by='id',
   point_color_by='color',
   link_source_by='source',
   link_target_by='target',
)

Configuration and Customization

The Cosmograph widget offers extensive configuration options to customize its appearance and behavior. For more detailed configuration options, please refer to the @cosmograph/cosmograph documentation.

Development installation

We'll assume you know how to create and manage virtual environments if you're that type of developper, but it's not necessary.

Clone the repo

git clone https://github.com/cosmograph-org/cosmograph_widget

or

git clone git@github.com:cosmograph-org/cosmograph_widget.git

Switch to dev branch

Go to the directory where you installed this

cd cosmograph_widget

Switch to dev branch

git checkout dev

Install from source

Install the package from source:

pip install -e ".[dev]"

Rebuild the JS side of the widget package

If you change the python side, effects will be automatic (baring import caching etc.).

If you change the JS side, to see the the effects, you'll need to build the JS side. From the root directory:

npm run build

If you want some "auto-build-and-load" server running to not have to build manually every time you change some JS code, from the root folder do:

npm run dev

Open example.ipynb in JupyterLab, VS Code, or your favorite editor to start developing. Changes made in js/ will be reflected in the notebook.

Linting Python Code

We use Ruff to lint our Python code. You can install Ruff via pipx install ruff or brew install ruff.

To lint the code, run ruff check (or pipx run ruff check) from the root directory of the project.

To format the code, run ruff format (or pipx run ruff format) from the root directory of the project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cosmograph_widget-0.0.4.tar.gz (254.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cosmograph_widget-0.0.4-py2.py3-none-any.whl (256.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file cosmograph_widget-0.0.4.tar.gz.

File metadata

  • Download URL: cosmograph_widget-0.0.4.tar.gz
  • Upload date:
  • Size: 254.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.6

File hashes

Hashes for cosmograph_widget-0.0.4.tar.gz
Algorithm Hash digest
SHA256 e28f6d9ed386eb1805b6f411cd891f687a227ace7edf3c3d87c7a6137d9945fa
MD5 c17700d520d9465ae881a1fcd2d4a2e6
BLAKE2b-256 97f0907ffff0b9850073075f9662f3f284d9d1b7c0ebbdfee48425cf1fce35f2

See more details on using hashes here.

File details

Details for the file cosmograph_widget-0.0.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for cosmograph_widget-0.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b8387e51e0115f298e7e066259caa0bf6cc268fc195c4a1916f0ab1ae28af179
MD5 99913d295fd2a98a422b0a1d7c47cbfb
BLAKE2b-256 516419f16dd5993f54df87e4fac952322855a24adc3b183b166dc292c96f976c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page