Skip to main content
Moonframe's banner containing the logo, the title of the repo and a subtitle : d3.js visuals with Python.

Moonframe

Moonframe is an open-source Python library that helps you create interactive graphs using D3.js without writing a single line of JavaScript.
It’s built for quick data exploration and aims to be as simple and accessible as possible.

Main features

Customizable charts without coding

Moonframe provides a simple user interface that handles all customization in real time, with no need to code. You can set the color palette, change the element properties (color, size, ...), filter the displayed data, and more.

Network graph demo. A menu on the left allows you to select a category to set the color scale, the size scale and group some of the nodes together. Scatter plot demo. With the menu on the left, you can change the color palette of the chart.

Dynamic navigation

All graphs are interactive and dynamic, thanks to D3.js. Navigate your way through click, hover, zoom, and pan.

Network graph demo. Panning and zooming interactions are shown. We also see the mouse grab a node and drag it to someanother location, untangling the visualization. Circular packing plot demo. After clicking on a circle, the view zooms in on that circle.

Ways of exploring your data

Moonframe lets you deeply explore your dataset: access your data with tooltips or cards, reveal relationships between elements with highlighting, flag important points, or hide useless ones.
You are also free to remove or add fields to be displayed in tooltips or cards.

Scatter plot demo. An option allows you to group points that share the same color group. As a result, when you hover over a point, all the points in the same group are shown. Click on a node to highlight its connections and display a data card with the selected node’s details. Unconnected nodes fade into the background, creating a clear visual contrast with the highlighted connections. You can also hover over any connected node to view its tooltip.

Others features

  • Easy to use
  • Handling missing data
  • Dark/light theme
  • Search

Usage

Moonframe handles web applications based on Flask. Each application is run on a server and is rendered in a web browser.

To keep things simple, Moonframe follows the philosophy: "one application = one graph". All available applications are stored in the app_builder module.

In practice, you can either include Moonframe directly in your Python projects:

from moonframe.app_builder import build_scatter_app
from moonframe.serve import serve_app

# Create a scatter plot app
app = build_scatter_app(filepath="dataset.csv", delimiter=";")
# Serve it locally
serve_app(app=app)

Or use it through the CLI:

> moonframe
Usage: moonframe [OPTIONS] COMMAND [ARGS]...

  Package moonframe v0.7.0

                  ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
                  ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣴⡶⠖⠋⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
                  ⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣴⣾⣿⠟⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
                  ⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣿⡿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
                  ⠀⠀⠀⠀⠀⠀⣰⣿⣿⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣶⣶⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
                  ⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣶⣶⡆⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
                  ⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⣶⣤⡄⠀⣿⣿⡇⠀⣿⣿⡇⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⠀
                  ⠀⠀⠀⠀⠀⠸⣿⣿⣿⣿⣿⡆⠀⣶⣶⡆⠀⣿⣿⡇⠀⣿⣿⡇⠀⣿⣿⡇⠀⠀⠀⠀⢠⠇⠀⠀⠀⠀⠀
                  ⠀⠀⠀⠀⠀⠀⢻⣿⣿⣿⣿⣿⣦⡙⢿⡇⠀⣿⣿⡇⠀⣿⣿⡇⠀⣿⣿⡇⠀⠀⢀⣴⡟⠀⠀⠀⠀⠀⠀
                  ⠀⠀⠀⠀⠀⠀⠀⠻⣿⣿⣿⣿⣿⣿⣦⣀⡀⠿⢿⡇⠀⣿⣿⡇⠀⡿⠿⢃⣠⣴⣿⠟⠀⠀⠀⠀⠀⠀⠀
                  ⠀⠀⠀⠀⠀⠀⠀⠀⠙⠿⣿⣿⣿⣿⣿⣿⣿⣷⣶⣦⣤⣭⣭⣤⣴⣶⣾⣿⣿⠿⠋⠀⠀⠀⠀⠀⠀⠀⠀
                  ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
                  ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠛⠛⠛⠛⠛⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

  ------------------------------  Moonframe  ------------------------------

  You are now using the Command line interface of moonframe package, a set of
  tools created at CERFACS (https://cerfacs.fr).

  This is a python package currently installed in your python environement.

  All graphs are displayed in your default web browser.

Options:
  --help  Show this message and exit.

Commands:
  circular-packing  Circular packing graph.
  network           Network graph.
  scatter           Scatter plot

Getting started

If you’re completely new to Python, the easiest way to begin is by following the getting started tutorial. This guide walks you through installing Moonframe and introduces a few essential basics. Give it a try!

Requirements

  • Web browser
  • Python >= 3.7
  • An internet connexion (just during graph generation, see Important note above)

Installation

Install it from PyPI with :

pip install moonframe

Available charts

Table of contents

Screenshot of a scatter graph.
Scatter
Screenshot of a circular packing graph.
Circular packing
Screenshot of a network graph.
Network

Scatter plot

The scatter plot displays data as points on a 2D axis. It is perfect to do quick data exploration on a variety of datasets.
It takes as input CSV files structured in columns. It must include a header row to name each column. For example, the film dataset from the personal website of James R. Eagan:

Year;Length;Title;Subject;Actor;Actress;Director;Popularity;Awards;*Image
1990;111;Tie Me Up! Tie Me Down!;Comedy;Banderas, Antonio;Abril, Victoria;AlmodÛvar, Pedro;68;No;NicholasCage.png
1991;113;High Heels;Comedy;BosÈ, Miguel;Abril, Victoria;AlmodÛvar, Pedro;68;No;NicholasCage.png
1983;104;Dead Zone, The;Horror;Walken, Christopher;Adams, Brooke;Cronenberg, David;79;No;NicholasCage.png

More on this subject on the dataset documentation.

You can open the scatter plot either using the following command:

moonframe scatter film.csv -d ";"

Or in your application:

from moonframe.app_builder import build_scatter_app
from moonframe.serve import serve_app

# Create a scatter plot app
app = build_scatter_app(filepath="film.csv", delimiter=";")
# Serve it locally
serve_app(app=app)

Learn more on the scatter plot documentation.

Circular packing

The circular packing graph displays hierarchical data as nested circles.
It takes as input JSON files looking like this:

{
  "root": {
    "field1": 5,
    "field2": true,
    "field3": "coffee",
    "field4": 1.5,
    "field5": ["hello", "world"],
    "field6": { "hello": 1, "world": 2 }
  },
  "root/element1": {
    "field1": 2,
    "field2": false,
    "field3": "tea",
    "field4": 3.2,
    "field5": ["hello", "world"],
    "field6": { "hello": 1, "world": 2 }
  }
}

Hierarchy is expresses as paths using "/" to separate the different levels. A common root is required to work.

You can open the graph either using the following command:

moonframe circular-packing dataset.json

Or directly in your application:

from moonframe.app_builder import build_app_circular_packing
from moonframe.serve import serve_app
from json import load

with open("dataset.json", "r") as file:
    data = load(file)

app = build_app_circular_packing(filedata=data, delimiter=";")
serve_app(app=app)

Learn more on the circular packing plot documentation.

Network

The network graph displays relationships between elements within a network as nodes and edges (links).
It takes as input NetworkX graph or a JSON file generated from one (using node_link_data, see the offical documentation).

For example, you can open a Network graph in a Python script:

import networkx as nx
from moonframe.app_builder import build_app_network
from moonframe.server import serve_app

# set the graph - example taken from https://networkx.org/documentation/latest/auto_examples/basic/plot_simple_graph.html
G = nx.Graph()
G.add_edge(1, 2)
G.add_edge(1, 3)
G.add_edge(1, 5)
G.add_edge(2, 3)
G.add_edge(3, 4)
G.add_edge(4, 5)

# create the graph and opens it with Moonframe
app = build_app_network(G, title="Simple Network")
serve_app(app)

Or using the following command:

moonframe network dataset.json

dataset.json is, in this case, the output of the NetworkX function node_link_data dumped to JSON:

data = nx.readwrite.json_graph.node_link_data(G)

with open("dataset.json", "w") as f:
    json.dump(data, f, indent=4)

Giving the following:

{
  "directed": false,
  "multigraph": false,
  "graph": {},
  "nodes": [
    {
      "id": 1
    },
    {
      "id": 2
    },
    {
      "id": 3
    },
    {
      "id": 5
    },
    {
      "id": 4
    }
  ],
  "edges": [
    {
      "source": 1,
      "target": 2
    },
    {
      "source": 1,
      "target": 3
    },
    {
      "source": 1,
      "target": 5
    },
    {
      "source": 2,
      "target": 3
    },
    {
      "source": 3,
      "target": 4
    },
    {
      "source": 5,
      "target": 4
    }
  ]
}

Learn more on the network graph documentation.

Most common troubleshoots

  • Wrong data format : Makes sure to double check the input data format requirements. You can take a look at the Dataset documentation. Be extra careful with the delimiter of your CSV file when using the scatter plot.
  • Internet connexion : Even though the graph is hosted locally, an internet connection is briefly required during generation to load the necessary packages.
  • Port number: If you manually set the port using the -p option, make sure the port is available and not reserved by your system. If unsure, simply run the application without specifying a port, this lets it automatically choose a suitable one.
  • Cache : If something isn't working as expected, try clearing your browser cache and restarting the application.
  • Version : Of course, make sure you are up-to-date. Run pip install --upgrade moonframe.
  • Not responsive: Either your dataset is too big and it takes a lot of time to load - either you have disconnect your server by closing your terminal or pression CTRL+D.

Metadata

Release files for moonframe 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moonframe 1.0.3
File Size Uploaded
moonframe-1.0.3.tar.gz 68.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for moonframe 1.0.3
File Interpreter ABI Platform
moonframe-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 149.8 kB

Release files / moonframe-1.0.3.tar.gz

Download URL moonframe-1.0.3.tar.gz
Size 68.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c58ae8dc2b9fb6c6e35b48543b63167db2ca6e68c65a062564cdee25e156299f
BLAKE2b-256 checksum
How to use checksums
66b8d193c46ef04c83416cba82896371ac72a2d6634d97023bc4f1a2e5a3cc09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.9

Release files / moonframe-1.0.3-py3-none-any.whl

Download URL moonframe-1.0.3-py3-none-any.whl
Size 81.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd13747138f65509c9997fa4552e5a87063047ac3a5e5538148a298a23db4c21
BLAKE2b-256 checksum
How to use checksums
cc1ba602268f1e4cc55dbbbee9583ccc9c6e9d4655efb0ece4378a50e2ec31c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.9

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.3.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page