ddd-subplots


Nameddd-subplots JSON
Version 1.0.27 PyPI version JSON
download
home_pagehttps://github.com/LucaCappelletti94/ddd_subplots
SummaryPython package making it easier to handle mixed 3d and 2d subplots.
upload_time2023-11-23 17:40:28
maintainer
docs_urlNone
authorLuca Cappelletti
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            DDD Subplots
=========================================================================================
|pip| |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:

.. code:: shell

    pip install ddd_subplots

Usage Example
-----------------------------------------------

3D subplots
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get a set of 3d subplots just import `subplots`:

.. code:: python

    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:

.. code:: python

    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:

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


.. |pip| image:: https://badge.fury.io/py/ddd-subplots.svg
    :target: https://badge.fury.io/py/ddd-subplots
    :alt: Pypi project

.. |downloads| image:: https://pepy.tech/badge/ddd-subplots
    :target: https://pepy.tech/badge/ddd-subplots
    :alt: Pypi total project downloads 



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/LucaCappelletti94/ddd_subplots",
    "name": "ddd-subplots",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Luca Cappelletti",
    "author_email": "cappelletti.luca94@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/7c/aa/d172cb7741873370af77e03ab828ae45dd54f0140ba157c2f593718db6eb/ddd_subplots-1.0.27.tar.gz",
    "platform": null,
    "description": "DDD Subplots\n=========================================================================================\n|pip| |downloads|\n\nPython package making it easier to handle mixed 3d and 2d subplots.\n\nHow do I install this package?\n----------------------------------------------\nAs usual, just download it using pip:\n\n.. code:: shell\n\n    pip install ddd_subplots\n\nUsage Example\n-----------------------------------------------\n\n3D subplots\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nTo get a set of 3d subplots just import `subplots`:\n\n.. code:: python\n\n    from ddd_subplots import subplots\n\n    fig, axes = subplots(1, 3, figsize=(15, 5))\n\n\nRotating 3D scatter plots\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nThe library also offers a method to render 3D scatter plots. Here's a complete example:\n\n.. code:: python\n\n    from ddd_subplots import subplots, rotate\n    import numpy as np\n    from sklearn import datasets\n    from sklearn.decomposition import PCA\n\n\n    def write_frame(X_reduced, y):\n        colors = np.array([\"red\", \"green\", \"blue\"])[y]\n        fig, axes = subplots(1, 3, figsize=(15, 5))\n        for axis in axes.flatten():\n            axis.scatter(*X_reduced.T, depthshade=False,\n                        c=colors, marker='o', s=20)\n        fig.tight_layout()\n        return fig, axes\n\n    X, y = datasets.load_iris(return_X_y=True)\n    X_reduced = PCA(n_components=3).fit_transform(X)\n\n    rotate(\n        write_frame,\n        X_reduced,\n        \"test_animation.gif\",\n        y,\n        duration=10,\n        verbose=True\n    )\n\n\nOutput:\n\n.. image:: https://github.com/LucaCappelletti94/ddd_subplots/blob/master/test_animation.gif?raw=true\n\n\n.. |pip| image:: https://badge.fury.io/py/ddd-subplots.svg\n    :target: https://badge.fury.io/py/ddd-subplots\n    :alt: Pypi project\n\n.. |downloads| image:: https://pepy.tech/badge/ddd-subplots\n    :target: https://pepy.tech/badge/ddd-subplots\n    :alt: Pypi total project downloads \n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python package making it easier to handle mixed 3d and 2d subplots.",
    "version": "1.0.27",
    "project_urls": {
        "Homepage": "https://github.com/LucaCappelletti94/ddd_subplots"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7caad172cb7741873370af77e03ab828ae45dd54f0140ba157c2f593718db6eb",
                "md5": "99adce151840ee0c40d3d9e7c158919b",
                "sha256": "925a61b888ee0491650cac022f28059e415486022a8ec33329c0555a0429f649"
            },
            "downloads": -1,
            "filename": "ddd_subplots-1.0.27.tar.gz",
            "has_sig": false,
            "md5_digest": "99adce151840ee0c40d3d9e7c158919b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7167,
            "upload_time": "2023-11-23T17:40:28",
            "upload_time_iso_8601": "2023-11-23T17:40:28.255125Z",
            "url": "https://files.pythonhosted.org/packages/7c/aa/d172cb7741873370af77e03ab828ae45dd54f0140ba157c2f593718db6eb/ddd_subplots-1.0.27.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-23 17:40:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "LucaCappelletti94",
    "github_project": "ddd_subplots",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ddd-subplots"
}
        
Elapsed time: 0.20048s