• Stars
    star
    452
  • Rank 93,387 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

D3 block magic for Jupyter notebook.

py_d3 PyPi version t

Deprecation notice

The py_d3 package has been retired. This package was only ever intended to work in the classical Jupyter Notebook environment, this has been replaced pretty much all applications by the more advanced and more feature-complete Jupyter Lab. Jupyter Lab has a completely different SDK for notebook extensions, which this package neither uses nor supports.

As such this package is now unmaintained.

For users looking for an interactive environment for building D3.JS visualizations in, I recommend Observable Notebooks.

For users looking to embed D3.JS visualizations in their Jupyter Lab notebooks, check out this Gist.

Happy plotting!

About

py_d3 is an IPython extension which adds D3 support to the Jupyter Notebook environment.

D3 is a powerful JavaScript data visualization library, while Jupyter is an intuitive browser-hosted Python development environment. Wouldn't it be great if you could use them together? Now you can.

Quickstart

You can install py_d3 by running pip install py_d3. Then load it into a Jupyter notebook by running%load_ext py_d3.

Use the %%d3 cell magic to define notebook cells with D3 content.

alt text

py_d3 allows you to express even very complex visual ideas within a Jupyter Notebook without much difficulty. A Radial Reingold-Tilford Tree, for example:

alt text

An interactive treemap (original):

alt text

Or even the entire D3 Show Reel animation:

alt text

For more examples refer to the examples notebooks.

Features

Configuration

The cell magic will default to loading the latest stable version of D3.JS available online (via CDNJS; [email protected] at time of writing). To load a specific version, append the version name to the command, e.g. %%d3 "3.5.17". To load D3.JS from a local file pass the filepath, e.g. %%d3 "d3.v5.min.js".

Only one version of D3.JS may be loaded at a time. Both 3.x and 4.x versions of D3 are supported, but you may only run one version of D3 per notebook. You can check which versions are available by running %d3 versions, and check which version is loaded in the current notebook using %d3 version.

Documentation

Pages from the D3 API Reference may be rendered in-notebook using %d3 doc. For example, you can render the d3-array reference by running %d3 doc "d3-array".

Verbose Mode

You can view code to-be-rendered using verbose mode: %d3 -v. This is helpful for debugging your application.

Technical

How it works

Jupyter notebooks allow executing arbitrary JavaScript code using IPython.display.JavaScript, however it makes no effort to restrict the level of DOM objects accessible to executable code. py_d3 works by restricting d3 scope to whatever cell you are running the code in, by monkey-patching the d3.select and d3.selectAll methods (see here for why this works).

Porting

Most HTML-hosted D3 visualizations, even very complex ones, can be made to run inside of a Jupyter Notebook %%d3 cell with just two modifications:

  • Remove any D3 imports in the cell (e.g. <script src="https://d3js.org/d3.v3.js"></script>).
  • Make sure to create and append to a legal HTML document sub-element. d3.select("body").append("g") won't work.

Contributing

See CONTRIBUTING.md for instructions on how to contribute.

More Repositories

1

missingno

Missing data visualization module for Python.
Python
3,634
star
2

geoplot

High-level geospatial data visualization library for Python.
Python
1,081
star
3

designing-data-intensive-applications-notes

Reading notes on the excellent "Designing Data-Intensive Applications"
Jupyter Notebook
196
star
4

boston-airbnb-geo

A Deep Dive into Geospatial Analysis in Python (Tutorial)
Jupyter Notebook
54
star
5

gtfs-tripify

Turn GTFS-RT transit updates into historical arrival data.
Python
41
star
6

wargame-data

An export of unit values from the strategic real-time strategy game Wargame: Red Dragon.
Jupyter Notebook
27
star
7

watsongraph

Concept discovery and recommendation library built on top of the IBM Watson cognitive API.
Python
24
star
8

progressive-resizing

Applying progressive resizing to building models in Keras.
Jupyter Notebook
18
star
9

checkpoints

Partial result caching for pandas in Python.
Python
16
star
10

hurdat2

Process files and docs for the standardization of NOAA HURDAT2 database.
Jupyter Notebook
14
star
11

geoplot-data

Raw data files used by the geoplot examples and documentation
11
star
12

advanced-pandas-exercises

https://www.kaggle.com/residentmario/advanced-pandas-exercises
Python
9
star
13

streetmapper

Geospatial tools for working with census blocks, street networks, building footprints in Python
Python
8
star
14

citibike

Data processing for a CitiBike trip data visualization.
Jupyter Notebook
8
star
15

socrata-portal-metadata

Python module for exploring Open Data Portal metadata.
Jupyter Notebook
8
star
16

data-science-team

Presentation materials from the prospective CUNY Baruch Data Science Competition Team.
HTML
7
star
17

wargame

A LaTeX guide to unit values in the strategic RTS game "Wargame: Red Dragon".
TeX
6
star
18

signpostviews

A Jupyter notebook and some associated files studying Signpost article viewership.
Jupyter Notebook
5
star
19

acris

Overview of the New York City Department of Finance's ACRIS dataset(s).
Jupyter Notebook
5
star
20

yellowbrick-x-keras

How to use the yellowbrick metrics dataviz library with keras
Jupyter Notebook
4
star
21

airscooter

Command-line utility for simple graph-based data workflows.
Python
4
star
22

python-missing-data

NOW A BLOG POST: http://www.residentmar.io/2016/06/12/null-and-missing-data-python.html
Jupyter Notebook
4
star
23

dt-guide

LaTeX guide written to accompany Dwarf Therapist.
TeX
4
star
24

motor-vehicle-collisions

Using NYPD Motor Vehicle Collisions data from the NYC Open Data portal to study traffic accidents in New York City.
Jupyter Notebook
4
star
25

chain-incidence

Data munging for the subject of http://www.residentmar.io/2016/02/09/average-chain-distance.html and http://gothamist.com/2016/02/09/starbucks_ubiquitous.php
HTML
3
star
26

co_reader

A module for retrieving recent NYC DOB certificate of occupancy issuance dates.
Python
3
star
27

pytorch-training-performance-guide

Guidebook and reference on PyTorch training optimizations
TeX
3
star
28

subway-explorer-api

API for ground-truth MTA subway arrival and departure times.
JavaScript
3
star
29

nyc-building-values

Jupyter Notebook
3
star
30

go-bike-sankey

http://www.residentmar.io/2019/01/15/ford-go-bike-maps.html
Jupyter Notebook
3
star
31

mta-data-exploration-old

Dev materials for what became the gtfs-tripify module
Jupyter Notebook
3
star
32

fahr

Run remote machine learning model training jobs right from the command line.
Python
3
star
33

machine-learning-notes

A microsite hosting my machine learning notes.
HTML
2
star
34

plotting-tools

Jupyter Notebook
2
star
35

rubbish-geo

Python
2
star
36

blogimporter

A script that handles tedius setup tasks for the Blog section of the Wikipedia Signpost.
Python
1
star
37

streaming-algos

Notebooks implementing a selection of streaming quantile algorithms.
Jupyter Notebook
1
star
38

data-structures-js

Implementing my way through a bunch of algos in JavaScript and Python.
Jupyter Notebook
1
star
39

coding-challenges-again

Jupyter Notebook
1
star
40

nyc-transit-archive-old

An archival service for NYC transit data.
Python
1
star
41

mysite

The source code for my personal website.
HTML
1
star
42

nyc-transit-archive

Jupyter Notebook
1
star
43

quilt-sagemaker-demo

Jupyter Notebook
1
star
44

neural-network-notes

My notes from Geoffrey Hinton's neural networks Coursera course
Jupyter Notebook
1
star
45

rust-learn

Rust
1
star
46

data-visualization-blogging

Slides from a presentation on blogging and you.
1
star
47

nyc-gentrification-1

HTML
1
star
48

nyc-active-construction-sites

HTML
1
star
49

trash-talk

Learnings from garbage.
Jupyter Notebook
1
star
50

airflow-playground

Python
1
star
51

geoplot-images

Test images for the geoplot library
1
star
52

nyc-tobacco

A calculation of mean distance to tobacco stores in NYC. Based on NYC Open Data.
Jupyter Notebook
1
star
53

nyc-real-estate-sales

Data munging for a blog post on real estate concentration in New York City.
Jupyter Notebook
1
star
54

implementing-good-design

The slides from a talk I gave for the NYC D3.JS Meetup on the data visualization design process.
1
star
55

subway-explorer-webapp

How long is your commute? Proof-of-concept ground-truth MTA subway arrival time web application.
JavaScript
1
star
56

watsongraph-tutorial

Tutorial materials for the watsongraph library.
Jupyter Notebook
1
star
57

fcimporter

A script that handles tedius setup tasks for the Featured Content Report section of the Wikipedia Signpost.
Python
1
star
58

nyc-buildings

Data munging for the subject of housing value data visualization and mining projects.
Jupyter Notebook
1
star