Giter Club home page Giter Club logo

ddd_subplots's Introduction

DDD Subplots

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

ddd_subplots's People

Contributors

lucacappelletti94 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

ddd_subplots's Issues

Update readme with the new my_func

def my_func(points: np.ndarray, *args, **kwargs):
    fig, axis = subplots(1, 1, figsize=(6, 6), dpi=200)
    s = axis.scatter(*points, **kwargs)
    axis.set_xticklabels([])
    axis.set_yticklabels([])
    axis.set_zticklabels([])
    axis.set_xlim(-0.25, 0.25)
    axis.set_ylim(-0.25, 0.25)
    axis.set_zlim(-0.25, 0.25)
    axis.set_axis_off()
    axis.set_title("3d-TSNE of the selected data colored by cohort.")
    axis.legend(
        handles=s.legend_elements()[0],
        labels=["Core", "Extended"],
        loc="lower right",
        title="Cohort",
    )
    return fig, axis
    ```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.