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
import os
from sklearn import datasets
from sklearn.preprocessing import MinMaxScaler
from sklearn.decomposition import PCA
from numpy.linalg import norm



def my_func(xs, ys, zs, *args, **kwargs):
    fig, axes = subplots(1, 3, figsize=(9, 3))
    X = MinMaxScaler().fit_transform(np.array([xs, ys, zs]).T)
    distances = 1-norm(X-np.array([1,1,1]), axis=1, ord=2)
    for axis in axes.flatten():
        axis.scatter(*X.T, **kwargs, zorder=distances)
    fig.tight_layout()
    return fig


def test_rotate():
    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, depthshade=False, c=colors, marker='o', s=20)

Output:

https://github.com/LucaCappelletti94/ddd_subplots/blob/master/test.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.1.tar.gz (4.8 kB view hashes)

Uploaded Source

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