Skip to main content

Library for plotting interactive graphs on Jupyter Notebook

Project description

Croquis: plot graphs 100x faster on Jupyter Notebook

Croquis is a lightweight Python library for drawing interactive graphs really fast on Jupyter Notebook. It lets you effortlessly browse and examine much larger data than other similar libraries.

banner

Install croquis by running:

pip install croquis

👉 Please look at the tutorial for more example.


You might be wondering: there are already many mature and feature-rich plotting libraries — what's the appeal of a new, experimental library? Well, croquis is built with the following goals in mind:

  • Fast: Croquis contains a multi-threaded C++ plotting engine which automatically parallelizes graph generation, easily handling gigabytes of data.
  • Simple: Croquis provides a unified, simple API, regardless of data size. Whether your data contains ten data points or fifty million, you can make the same three function calls (or as many calls as you wish in a loop, if you prefer). The library will handle the rest.
  • Interactive: Since the C++ engine is alive as long as your figure is visible, at any moment you can zoom in, move around, or select a different subset of your data, and the figure will update accordingly.

As an example, here's hourly ground temperature data of 2020 from the world's weather stations, downloaded from NOAA website. The data set contains 127 million points.

https://user-images.githubusercontent.com/31876421/123535161-0b402d00-d6d7-11eb-9486-6218279eda9d.mp4

The word "croquis" means a quick, sketchy drawing - it's from French croquis which simply means "sketch." (The final -s is silent: it's French, after all.)

Requirements

  • 64-bit Linux running on x86 with AVX2 instruction set support. (Intel: Haswell (2013) or later; AMD: Excavator (2015) or later.)
    • I might add Mac OS (ARM, aka Apple Silicon) and Windows x86 support later... if I get enough free time. (Sorry, no concrete plan yet!)
  • Python 3.9 or later.
  • Jupyter Notebook.
  • A modern browser (if it can run Jupyter Notebook, it's probably fine).

How to install

pip install croquis

For building from the source, see DEVELOPMENT.md.

To test if it's working correctly, try this inside Jupyter Notebook:

# Paste into a Jupyter cell.

import croquis
import numpy as np

N = 1000000
X = np.random.normal(size=(N, 1))
Y = np.random.normal(size=(N, 1))
labels=['pt %d' % i for i in range(N)]

fig = croquis.plot()
fig.add(X, Y, marker_size=3, labels=labels)
fig.show()

It should generate a plot like this:

Gaussian distribution example

For documentation, see the tutorial and the (very short) reference.

Limitations

Croquis is still experimental: as of version 0.1, we only support the absolute bare minimum functionality. In particular:

  • Only line plots are supported, nothing else: no bars, pie charts, heatmaps, etc.
  • All lines are solid: no dotted/dashed lines.
  • All markers are solid circles: no other shapes are currently supported.
  • No subplots: each Jupyter cell can contain only one graph.
  • Very few options to customize the plot. No titles, axis labels, or secondary axes.
  • No support for mobile browsers.
  • No dark mode.
  • As you can see, the UI is rather primitive.

If croquis seems useful to you, but some features are missing for your use case, then please feel free to file an issue. (Of course I can't guarantee anything, but it will be nice to know that someone's interested.)

FAQ

Is it really 100 times faster?

With large data, croquis can be several hundred times faster than other popular libraries. With very small data, there's less difference, as fixed-size overheads start to dominate.

Can we use it outside of Jupyter Notebook?

No, croquis is currently tied to Jupyter's message passing architecture, and all computation is done in the backend, so it needs an active Jupyter Python kernel.

How does it work?

Unlike most other similar libraries, croquis works by running a C++ "tile server," which computes fixed-sized "tiles" which is then sent back to the browser. If you have used Google Maps, the idea should be familiar. This has an important advantage:

  • The browser only has to know about tiles. Hence, the size of the data the browser needs to know is independent of the data set size.

As a result, the browser stays lean and "snappy" even with massive data. (As explained in the reference, we support copy_data=False option that even eliminates data copies altogether.)

Moreover, unlike the browser's single-threaded javascript code, the C++-based tile server can draw multiple tiles in parallel, which allows even more speedup.

(On the other hand, there are drawbacks - we have to basically re-implement every graph drawing algorithm inside this tile server, not being able to use any javascript API, except for very trivial things like coordinate grids.)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

croquis-0.2.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (262.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

croquis-0.2.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (262.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

croquis-0.2.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (259.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

croquis-0.2.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (258.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

croquis-0.2.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (257.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file croquis-0.2.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for croquis-0.2.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 77bbdc2d4ee2fcbec4e15e3e08d029245314ffa6b6fa785fee8ee61b2f66db46
MD5 a184e8037ff594a43bc4bfb27dd08065
BLAKE2b-256 dfb24d28f65a67e8a14cdc3d363660746018e4e6e6d16c037ab11f1ac5fcf38c

See more details on using hashes here.

File details

Details for the file croquis-0.2.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for croquis-0.2.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a8902c7f818614bb0d54c0350c4e29ed434d11b710fd000c706c2214e86d794f
MD5 4e571340685005c2c1125e7641e993a3
BLAKE2b-256 8ec7de6a55de68f66f792bf4e606dec8c71d27818fb3ed32dd64102f3ea7737f

See more details on using hashes here.

File details

Details for the file croquis-0.2.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for croquis-0.2.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3ef87fc44a5ed8622f99ec8712f069d5c97008a409dae283c5389ee1bc889c77
MD5 28c1d2e0d963a4511b6700ec53b2718d
BLAKE2b-256 953c3ae12120b5407114c3bff85225c337c1f1edada538e97e70f3ba1c07bd54

See more details on using hashes here.

File details

Details for the file croquis-0.2.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for croquis-0.2.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5ae00a449845061bff78f6f263bc33e5f91082249cef67dbee6da22d3e2b8356
MD5 5f3c4d2a273b9246982757c41a2c3ca5
BLAKE2b-256 8012ec5446123df60ae94cd60af36aaa826aebd2f01e0961673dae0821175c46

See more details on using hashes here.

File details

Details for the file croquis-0.2.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for croquis-0.2.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ae2a5d13e8b4cc8709c25d094cde3ce0b03a04c92cc35e69d3fc788730e57905
MD5 014d60ba48150e77ea92da84cb82e5d6
BLAKE2b-256 5536eac6ceb9f17bc08664b78fc85348a43eaa5e1fceb32c162491a46d50b493

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