ridgeplot


Nameridgeplot JSON
Version 0.3.0 PyPI version JSON
download
home_pageNone
SummaryBeautiful ridgeline plots in python
upload_time2024-12-05 00:46:06
maintainerNone
docs_urlNone
authorTomas Pereira de Vasconcelos
requires_python>=3.9
licenseThe MIT License (MIT) Copyright (c) 2021-2024 Tomas Pereira de Vasconcelos Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords ridgeline ridgeplot joyplot ggridges ridges ridge plot plotting distplot plotly data-visualization
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            <p align="center">
    <img src="docs/_static/img/logo-wide.png#gh-light-mode-only" alt="ridgeplot - beautiful ridgeline plots in Python">
    <img src="docs/_static/img/logo-wide-dark.png#gh-dark-mode-only" alt="ridgeplot - beautiful ridgeline plots in Python">
</p>

<h1 id="ridgeplot" align="center">
    ridgeplot: beautiful ridgeline plots in Python
</h1>

<p align="center">
  <!-- TODO: https://bestpractices.coreinfrastructure.org/en -->
  <!-- TODO: https://www.gitpod.io/docs/getting-started -->
  <a href="https://pypi.org/project/ridgeplot/"><img src="https://img.shields.io/pypi/v/ridgeplot" alt="PyPI - Latest Release"></a>
  <a href="https://github.com/tpvasconcelos/ridgeplot/"><img src="https://img.shields.io/pypi/pyversions/ridgeplot" alt="PyPI - Python Versions"></a>
  <a href="https://pepy.tech/project/ridgeplot"><img src="https://img.shields.io/pepy/dt/ridgeplot" alt="Pepy Total Downloads"></a>
  <a href="https://pypi.org/project/ridgeplot/"><img src="https://img.shields.io/pypi/status/ridgeplot.svg" alt="PyPI - Package Status"></a>
  <a href="https://github.com/tpvasconcelos/ridgeplot/blob/main/LICENSE"><img src="https://img.shields.io/pypi/l/ridgeplot" alt="PyPI - License"></a>
  <br>
  <a href="https://github.com/tpvasconcelos/ridgeplot/actions/workflows/ci.yml/"><img src="https://github.com/tpvasconcelos/ridgeplot/actions/workflows/ci.yml/badge.svg" alt="GitHub CI"></a>
  <a href="https://github.com/tpvasconcelos/ridgeplot/actions/workflows/codeql.yml/"><img src="https://github.com/tpvasconcelos/ridgeplot/actions/workflows/codeql.yml/badge.svg" alt="CodeQL"></a>
  <a href="https://ridgeplot.readthedocs.io/en/latest/"><img src="https://readthedocs.org/projects/ridgeplot/badge/?version=latest&style=flat" alt="Docs"></a>
  <a href="https://codecov.io/gh/tpvasconcelos/ridgeplot"><img src="https://codecov.io/gh/tpvasconcelos/ridgeplot/branch/main/graph/badge.svg" alt="codecov"></a>
  <a href="https://www.codefactor.io/repository/github/tpvasconcelos/ridgeplot"><img src="https://www.codefactor.io/repository/github/tpvasconcelos/ridgeplot/badge" alt="CodeFactor"></a>
  <a href="https://app.codacy.com/gh/tpvasconcelos/ridgeplot/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade"><img src="https://app.codacy.com/project/badge/Grade/e21652ac49874b6f94ed3c9b7ac77021" alt="Codacy code quality Badge"></a>
</p>

-----------------

`ridgeplot` is a Python package that provides a simple interface for plotting beautiful and interactive [ridgeline plots](https://ridgeplot.readthedocs.io/en/stable/getting_started/getting_started.html) within the extensive [Plotly](https://plotly.com/python/) ecosystem.

## Installation

`ridgeplot` can be installed and updated from [PyPi](https://pypi.org/project/ridgeplot/) using [pip](https://pip.pypa.io/en/stable/quickstart/):

```shell
pip install -U ridgeplot
```

For more information, see the [installation guide](https://ridgeplot.readthedocs.io/en/stable/getting_started/installation.html).

## Getting started

Take a look at the [getting started guide](https://ridgeplot.readthedocs.io/en/stable/getting_started/getting_started.html), which provides a quick introduction to the `ridgeplot` library.

The full official documentation can be found at: https://ridgeplot.readthedocs.io/en/stable/

### Basic example

For those in a hurry, here's a very basic example on how to quickly get started with [ridgeplot()](https://ridgeplot.readthedocs.io/en/stable/api/public/ridgeplot.ridgeplot.html) function.

```python
import numpy as np
from ridgeplot import ridgeplot

my_samples = [np.random.normal(n / 1.2, size=600) for n in range(7, 0, -1)]
fig = ridgeplot(samples=my_samples)
fig.show()
```

![ridgeline plot example using the ridgeplot Python library](docs/_static/charts/basic.webp)

### Flexible configuration

In this example, we will try to replicate the first ridgeline plot in this [_from Data to Viz_ post](https://www.data-to-viz.com/graph/ridgeline.html). The example in the post was created using the [_"Perception of Probability Words"_ dataset](https://ridgeplot.readthedocs.io/en/stable/api/public/ridgeplot.datasets.load_probly.html) and the popular [ggridges](https://wilkelab.org/ggridges/) R package. In the end, we will see how the `ridgeplot` Python library can be used to create a (nearly) identical plot, thanks to its extensive configuration options.

```python
import numpy as np
from ridgeplot import ridgeplot
from ridgeplot.datasets import load_probly

# Load the probly dataset
df = load_probly()

# Let's grab the subset of columns used in the example
column_names = [
    "Almost Certainly",
    "Very Good Chance",
    "We Believe",
    "Likely",
    "About Even",
    "Little Chance",
    "Chances Are Slight",
    "Almost No Chance",
]
df = df[column_names]

# Not only does 'ridgeplot(...)' come configured with sensible defaults
# but is also fully configurable to your own style and preference!
fig = ridgeplot(
    samples=df.to_numpy().T,
    bandwidth=4,
    kde_points=np.linspace(-12.5, 112.5, 500),
    colorscale="viridis",
    colormode="row-index",
    opacity=0.6,
    labels=column_names,
    spacing=5 / 9,
)

# And you can still update and extend the final
# Plotly Figure using standard Plotly methods
fig.update_layout(
    height=560,
    width=800,
    font_size=16,
    plot_bgcolor="white",
    xaxis_tickvals=[-12.5, 0, 12.5, 25, 37.5, 50, 62.5, 75, 87.5, 100, 112.5],
    xaxis_ticktext=["", "0", "", "25", "", "50", "", "75", "", "100", ""],
    xaxis_gridcolor="rgba(0, 0, 0, 0.1)",
    yaxis_gridcolor="rgba(0, 0, 0, 0.1)",
    yaxis_title=dict(text="Assigned Probability (%)", font_size=13),
    showlegend=False,
)

# Show us the work!
fig.show()
```

![ridgeline plot of the probly dataset using the ridgeplot Python library](docs/_static/charts/probly.webp)

### More examples

For more examples, take a look at the [getting started guide](https://ridgeplot.readthedocs.io/en/stable/getting_started/getting_started.html). For instance, this example demonstrates how you can also draw [multiple traces](https://ridgeplot.readthedocs.io/en/stable/getting_started/getting_started.html#more-traces) per row in your ridgeline plot:

```python
import numpy as np
from ridgeplot import ridgeplot
from ridgeplot.datasets import load_lincoln_weather

# Load test data
df = load_lincoln_weather()

# Transform the data into a 3D (ragged) array format of
# daily min and max temperature samples per month
months = df.index.month_name().unique()
samples = [
    [
        df[df.index.month_name() == month]["Min Temperature [F]"],
        df[df.index.month_name() == month]["Max Temperature [F]"],
    ]
    for month in months
]

# And finish by styling it up to your liking!
fig = ridgeplot(
    samples=samples,
    labels=months,
    colorscale="Inferno",
    bandwidth=4,
    kde_points=np.linspace(-40, 110, 400),
    spacing=0.3,
)
fig.update_layout(
    title="Minimum and maximum daily temperatures in Lincoln, NE (2016)",
    height=600,
    width=800,
    font_size=14,
    plot_bgcolor="rgb(245, 245, 245)",
    xaxis_gridcolor="white",
    yaxis_gridcolor="white",
    xaxis_gridwidth=2,
    yaxis_title="Month",
    xaxis_title="Temperature [F]",
    showlegend=False,
)
fig.show()
```

![ridgeline plot of the Lincoln Weather dataset using the ridgeplot Python library](docs/_static/charts/lincoln_weather.webp)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ridgeplot",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Tomas Pereira de Vasconcelos <tomasvasconcelos1@gmail.com>",
    "keywords": "ridgeline, ridgeplot, joyplot, ggridges, ridges, ridge, plot, plotting, distplot, plotly, data-visualization",
    "author": "Tomas Pereira de Vasconcelos",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/52/26/8cf2a5b9ca581d577cacafe40c02c11c435719b19bea80aeca9af99df06d/ridgeplot-0.3.0.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n    <img src=\"docs/_static/img/logo-wide.png#gh-light-mode-only\" alt=\"ridgeplot - beautiful ridgeline plots in Python\">\n    <img src=\"docs/_static/img/logo-wide-dark.png#gh-dark-mode-only\" alt=\"ridgeplot - beautiful ridgeline plots in Python\">\n</p>\n\n<h1 id=\"ridgeplot\" align=\"center\">\n    ridgeplot: beautiful ridgeline plots in Python\n</h1>\n\n<p align=\"center\">\n  <!-- TODO: https://bestpractices.coreinfrastructure.org/en -->\n  <!-- TODO: https://www.gitpod.io/docs/getting-started -->\n  <a href=\"https://pypi.org/project/ridgeplot/\"><img src=\"https://img.shields.io/pypi/v/ridgeplot\" alt=\"PyPI - Latest Release\"></a>\n  <a href=\"https://github.com/tpvasconcelos/ridgeplot/\"><img src=\"https://img.shields.io/pypi/pyversions/ridgeplot\" alt=\"PyPI - Python Versions\"></a>\n  <a href=\"https://pepy.tech/project/ridgeplot\"><img src=\"https://img.shields.io/pepy/dt/ridgeplot\" alt=\"Pepy Total Downloads\"></a>\n  <a href=\"https://pypi.org/project/ridgeplot/\"><img src=\"https://img.shields.io/pypi/status/ridgeplot.svg\" alt=\"PyPI - Package Status\"></a>\n  <a href=\"https://github.com/tpvasconcelos/ridgeplot/blob/main/LICENSE\"><img src=\"https://img.shields.io/pypi/l/ridgeplot\" alt=\"PyPI - License\"></a>\n  <br>\n  <a href=\"https://github.com/tpvasconcelos/ridgeplot/actions/workflows/ci.yml/\"><img src=\"https://github.com/tpvasconcelos/ridgeplot/actions/workflows/ci.yml/badge.svg\" alt=\"GitHub CI\"></a>\n  <a href=\"https://github.com/tpvasconcelos/ridgeplot/actions/workflows/codeql.yml/\"><img src=\"https://github.com/tpvasconcelos/ridgeplot/actions/workflows/codeql.yml/badge.svg\" alt=\"CodeQL\"></a>\n  <a href=\"https://ridgeplot.readthedocs.io/en/latest/\"><img src=\"https://readthedocs.org/projects/ridgeplot/badge/?version=latest&style=flat\" alt=\"Docs\"></a>\n  <a href=\"https://codecov.io/gh/tpvasconcelos/ridgeplot\"><img src=\"https://codecov.io/gh/tpvasconcelos/ridgeplot/branch/main/graph/badge.svg\" alt=\"codecov\"></a>\n  <a href=\"https://www.codefactor.io/repository/github/tpvasconcelos/ridgeplot\"><img src=\"https://www.codefactor.io/repository/github/tpvasconcelos/ridgeplot/badge\" alt=\"CodeFactor\"></a>\n  <a href=\"https://app.codacy.com/gh/tpvasconcelos/ridgeplot/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade\"><img src=\"https://app.codacy.com/project/badge/Grade/e21652ac49874b6f94ed3c9b7ac77021\" alt=\"Codacy code quality Badge\"></a>\n</p>\n\n-----------------\n\n`ridgeplot` is a Python package that provides a simple interface for plotting beautiful and interactive [ridgeline plots](https://ridgeplot.readthedocs.io/en/stable/getting_started/getting_started.html) within the extensive [Plotly](https://plotly.com/python/) ecosystem.\n\n## Installation\n\n`ridgeplot` can be installed and updated from [PyPi](https://pypi.org/project/ridgeplot/) using [pip](https://pip.pypa.io/en/stable/quickstart/):\n\n```shell\npip install -U ridgeplot\n```\n\nFor more information, see the [installation guide](https://ridgeplot.readthedocs.io/en/stable/getting_started/installation.html).\n\n## Getting started\n\nTake a look at the [getting started guide](https://ridgeplot.readthedocs.io/en/stable/getting_started/getting_started.html), which provides a quick introduction to the `ridgeplot` library.\n\nThe full official documentation can be found at: https://ridgeplot.readthedocs.io/en/stable/\n\n### Basic example\n\nFor those in a hurry, here's a very basic example on how to quickly get started with [ridgeplot()](https://ridgeplot.readthedocs.io/en/stable/api/public/ridgeplot.ridgeplot.html) function.\n\n```python\nimport numpy as np\nfrom ridgeplot import ridgeplot\n\nmy_samples = [np.random.normal(n / 1.2, size=600) for n in range(7, 0, -1)]\nfig = ridgeplot(samples=my_samples)\nfig.show()\n```\n\n![ridgeline plot example using the ridgeplot Python library](docs/_static/charts/basic.webp)\n\n### Flexible configuration\n\nIn this example, we will try to replicate the first ridgeline plot in this [_from Data to Viz_ post](https://www.data-to-viz.com/graph/ridgeline.html). The example in the post was created using the [_\"Perception of Probability Words\"_ dataset](https://ridgeplot.readthedocs.io/en/stable/api/public/ridgeplot.datasets.load_probly.html) and the popular [ggridges](https://wilkelab.org/ggridges/) R package. In the end, we will see how the `ridgeplot` Python library can be used to create a (nearly) identical plot, thanks to its extensive configuration options.\n\n```python\nimport numpy as np\nfrom ridgeplot import ridgeplot\nfrom ridgeplot.datasets import load_probly\n\n# Load the probly dataset\ndf = load_probly()\n\n# Let's grab the subset of columns used in the example\ncolumn_names = [\n    \"Almost Certainly\",\n    \"Very Good Chance\",\n    \"We Believe\",\n    \"Likely\",\n    \"About Even\",\n    \"Little Chance\",\n    \"Chances Are Slight\",\n    \"Almost No Chance\",\n]\ndf = df[column_names]\n\n# Not only does 'ridgeplot(...)' come configured with sensible defaults\n# but is also fully configurable to your own style and preference!\nfig = ridgeplot(\n    samples=df.to_numpy().T,\n    bandwidth=4,\n    kde_points=np.linspace(-12.5, 112.5, 500),\n    colorscale=\"viridis\",\n    colormode=\"row-index\",\n    opacity=0.6,\n    labels=column_names,\n    spacing=5 / 9,\n)\n\n# And you can still update and extend the final\n# Plotly Figure using standard Plotly methods\nfig.update_layout(\n    height=560,\n    width=800,\n    font_size=16,\n    plot_bgcolor=\"white\",\n    xaxis_tickvals=[-12.5, 0, 12.5, 25, 37.5, 50, 62.5, 75, 87.5, 100, 112.5],\n    xaxis_ticktext=[\"\", \"0\", \"\", \"25\", \"\", \"50\", \"\", \"75\", \"\", \"100\", \"\"],\n    xaxis_gridcolor=\"rgba(0, 0, 0, 0.1)\",\n    yaxis_gridcolor=\"rgba(0, 0, 0, 0.1)\",\n    yaxis_title=dict(text=\"Assigned Probability (%)\", font_size=13),\n    showlegend=False,\n)\n\n# Show us the work!\nfig.show()\n```\n\n![ridgeline plot of the probly dataset using the ridgeplot Python library](docs/_static/charts/probly.webp)\n\n### More examples\n\nFor more examples, take a look at the [getting started guide](https://ridgeplot.readthedocs.io/en/stable/getting_started/getting_started.html). For instance, this example demonstrates how you can also draw [multiple traces](https://ridgeplot.readthedocs.io/en/stable/getting_started/getting_started.html#more-traces) per row in your ridgeline plot:\n\n```python\nimport numpy as np\nfrom ridgeplot import ridgeplot\nfrom ridgeplot.datasets import load_lincoln_weather\n\n# Load test data\ndf = load_lincoln_weather()\n\n# Transform the data into a 3D (ragged) array format of\n# daily min and max temperature samples per month\nmonths = df.index.month_name().unique()\nsamples = [\n    [\n        df[df.index.month_name() == month][\"Min Temperature [F]\"],\n        df[df.index.month_name() == month][\"Max Temperature [F]\"],\n    ]\n    for month in months\n]\n\n# And finish by styling it up to your liking!\nfig = ridgeplot(\n    samples=samples,\n    labels=months,\n    colorscale=\"Inferno\",\n    bandwidth=4,\n    kde_points=np.linspace(-40, 110, 400),\n    spacing=0.3,\n)\nfig.update_layout(\n    title=\"Minimum and maximum daily temperatures in Lincoln, NE (2016)\",\n    height=600,\n    width=800,\n    font_size=14,\n    plot_bgcolor=\"rgb(245, 245, 245)\",\n    xaxis_gridcolor=\"white\",\n    yaxis_gridcolor=\"white\",\n    xaxis_gridwidth=2,\n    yaxis_title=\"Month\",\n    xaxis_title=\"Temperature [F]\",\n    showlegend=False,\n)\nfig.show()\n```\n\n![ridgeline plot of the Lincoln Weather dataset using the ridgeplot Python library](docs/_static/charts/lincoln_weather.webp)\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)  Copyright (c) 2021-2024 Tomas Pereira de Vasconcelos  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Beautiful ridgeline plots in python",
    "version": "0.3.0",
    "project_urls": {
        "Changelog": "https://ridgeplot.readthedocs.io/en/stable/reference/changelog.html",
        "Documentation": "https://ridgeplot.readthedocs.io/en/stable/",
        "Homepage": "https://github.com/tpvasconcelos/ridgeplot",
        "Issue Tracker": "https://github.com/tpvasconcelos/ridgeplot/issues",
        "Source code": "https://github.com/tpvasconcelos/ridgeplot"
    },
    "split_keywords": [
        "ridgeline",
        " ridgeplot",
        " joyplot",
        " ggridges",
        " ridges",
        " ridge",
        " plot",
        " plotting",
        " distplot",
        " plotly",
        " data-visualization"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7c7667e284bfbc367c3ff32d04749607b330c29c8d5045c714c00a2b34a332ab",
                "md5": "3ac637020d283b0f190427b6ab34da62",
                "sha256": "cf1755f55ec102f552c98b648106bea6beedf72bfdfe719afbace21f489a06fe"
            },
            "downloads": -1,
            "filename": "ridgeplot-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3ac637020d283b0f190427b6ab34da62",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 56846,
            "upload_time": "2024-12-05T00:46:04",
            "upload_time_iso_8601": "2024-12-05T00:46:04.491740Z",
            "url": "https://files.pythonhosted.org/packages/7c/76/67e284bfbc367c3ff32d04749607b330c29c8d5045c714c00a2b34a332ab/ridgeplot-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "52268cf2a5b9ca581d577cacafe40c02c11c435719b19bea80aeca9af99df06d",
                "md5": "a78c9736f75a599a87352f18e6054cf2",
                "sha256": "40367de914cc9c902e865995f947cbb8dc514cb4d92158e47536f2a40e733047"
            },
            "downloads": -1,
            "filename": "ridgeplot-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a78c9736f75a599a87352f18e6054cf2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 2089644,
            "upload_time": "2024-12-05T00:46:06",
            "upload_time_iso_8601": "2024-12-05T00:46:06.662560Z",
            "url": "https://files.pythonhosted.org/packages/52/26/8cf2a5b9ca581d577cacafe40c02c11c435719b19bea80aeca9af99df06d/ridgeplot-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-05 00:46:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tpvasconcelos",
    "github_project": "ridgeplot",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "ridgeplot"
}
        
Elapsed time: 0.88797s