Skip to main content

Python package making it easier to handle mixed 3d and 2d subplots.

Project description

Travis CI build SonarCloud Quality SonarCloud Maintainability Codacy Maintainability Maintainability Pypi project Pypi total project downloads

Python package making it easier to handle mixed 3d and 2d subplots.

How do I install this package?

As usual, just download it using pip:

pip install ddd_subplots

Tests Coverage

Since some software handling coverages sometime get slightly different results, here’s three of them:

Coveralls Coverage SonarCloud Coverage Code Climate Coverate

Usage Example

3D subplots

To get a set of 3d subplots just import subplots:

from ddd_subplots import subplots

fig, axes = subplots(1, 3, figsize=(15, 5))

Rotating 3D scatter plots

The library also offers a method to render 3D scatter plots. Here’s a complete example:

from ddd_subplots import subplots, rotate
import numpy as np
from sklearn import datasets
from sklearn.decomposition import PCA


def my_func(xs: np.ndarray, ys: np.ndarray, zs: np.ndarray, *args, **kwargs):
    fig, axes = subplots(1, 3, figsize=(9, 3))
    axs = axes.flatten()
    axs[0].scatter(xs, ys, zs, **kwargs)
    axs[1].scatter(ys, zs, xs, **kwargs)
    axs[2].scatter(zs, xs, ys, **kwargs)
    fig.tight_layout()
    return fig, axes


X, y = datasets.load_iris(return_X_y=True)
X_reduced = PCA(n_components=3).fit_transform(X)
colors = np.array(["red", "green", "blue"])[y]
rotate(my_func, *X_reduced.T, path="test.gif",
    duration=2, fps=24, c=colors, marker='o', s=20)

Output:

https://github.com/LucaCappelletti94/ddd_subplots/blob/master/test.gif?raw=true

Known limits

There is an error with CoreFoundations and multiprocessing on MacOS, which states the following:

The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.

This is a weird known error of MacOS Sierra. For now, the only available solution is to disable multiprocessing when dealing with matplotlib. Any alternative valid solutions are welcome:

rotate(my_func, *X_reduced.T, path="test.gif",
    duration=2, fps=24, parallelize=False, c=colors, marker='o', s=20)

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

ddd_subplots-1.0.17.tar.gz (7.1 kB view details)

Uploaded Source

File details

Details for the file ddd_subplots-1.0.17.tar.gz.

File metadata

  • Download URL: ddd_subplots-1.0.17.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.10

File hashes

Hashes for ddd_subplots-1.0.17.tar.gz
Algorithm Hash digest
SHA256 0da131a25e23aa00fb71bda771549ac2889872f2b53dbbd180a1074cfea858b3
MD5 8d3c7ea70997cfacf22e853fa3f111c0
BLAKE2b-256 9c87e7978a49bba0e0c74b8da58ca8b4e742c4c9f38e3aa38f00e6931993c78e

See more details on using hashes here.

Provenance

Supported by

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