Skip to main content

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

Project description

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

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 write_frame(X_reduced, y):
    colors = np.array(["red", "green", "blue"])[y]
    fig, axes = subplots(1, 3, figsize=(15, 5))
    for axis in axes.flatten():
        axis.scatter(*X_reduced.T, depthshade=False,
                    c=colors, marker='o', s=20)
    fig.tight_layout()
    return fig, axes

X, y = datasets.load_iris(return_X_y=True)
X_reduced = PCA(n_components=3).fit_transform(X)

rotate(
    write_frame,
    X_reduced,
    "test_animation.gif",
    y,
    duration=10,
    verbose=True
)

Output:

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

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.26.tar.gz (6.8 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: ddd_subplots-1.0.26.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.9

File hashes

Hashes for ddd_subplots-1.0.26.tar.gz
Algorithm Hash digest
SHA256 5e0fad926b5570ceac3f00a1bea9c21eca5f737926ac40ac4820eca594e89b71
MD5 f3b36ef0a93118e61792b9d43d6f0bc8
BLAKE2b-256 2719f01a288e8bd78369e92c7904494c5b05b5ebe6b139e7161f2cd8e2336442

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