Skip to main content

Beautiful ridgeline plots in python

Reason this release was yanked:

https://github.com/tpvasconcelos/ridgeplot/issues/1

Project description

ridgeplot - beautiful ridgeline plots in Python

ridgeplot: beautiful ridgeline plots in Python

PyPI - Latest Release PyPI - Python Versions PyPI - Package Status PyPI - License Code style: black
GitHub CI codecov CodeFactor Codacy code quality Requirements Status


The ridgeplot python library aims at providing a simple API for plotting beautiful ridgeline plots within the extensive Plotly interactive graphing environment.

Bumper stickers:

  • Do one thing, and do it well!
  • Use sensible defaults, but allow for extensive configuration!

How to get it?

The source code is currently hosted on GitHub at: https://github.com/tpvasconcelos/ridgeplot

Install and update using pip:

pip install -U ridgeplot

Dependencies

  • plotly - the interactive graphing backend that powers ridgeplot
  • statsmodels - Used for Kernel Density Estimation (KDE)
  • numpy - Supporting library for multi-dimensional array manipulations

How to use it?

Sensible defaults

from numpy.random import normal
from ridgeplot import ridgeplot

synthetic_samples = [normal(n / 1.2, size=600) for n in reversed(range(9))]
fig = ridgeplot(samples=synthetic_samples)
fig.show()

ridgeline plot example using the ridgeplot Python library

Fully configurable

In this example, we will be replicating the first ridgeline plot example in this from Data to Viz post, which uses the probly dataset. You can find the plobly dataset on multiple sources like in the bokeh python interactive visualization library. I'll be using the same source used in the original post.

import numpy as np
import pandas as pd
from ridgeplot import ridgeplot


# Get the raw data
df = pd.read_csv("https://raw.githubusercontent.com/bokeh/bokeh/main/bokeh/sampledata/_data/probly.csv")

# Let's grab only the subset of columns displayed 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.values.T,
    bandwidth=4,
    kde_points=np.linspace(-12.5, 112.5, 400),
    colorscale="viridis",
    colormode="index",
    coloralpha=0.6,
    labels=column_names,
    spacing=5 / 9,
)

# Again, update the figure layout to your liking here
fig.update_layout(
    title="What probability would you assign to the phrase <i>“Highly likely”</i>?",
    height=650,
    width=800,
    plot_bgcolor="rgba(255, 255, 255, 0.0)",
    xaxis_gridcolor="rgba(0, 0, 0, 0.1)",
    yaxis_gridcolor="rgba(0, 0, 0, 0.1)",
    yaxis_title="Assigned Probability (%)",
)
fig.show()

ridgeline plot of the probly dataset using the ridgeplot Python library

Alternatives

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

ridgeplot-0.1.10.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ridgeplot-0.1.10-py2.py3-none-any.whl (13.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ridgeplot-0.1.10.tar.gz.

File metadata

  • Download URL: ridgeplot-0.1.10.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.10

File hashes

Hashes for ridgeplot-0.1.10.tar.gz
Algorithm Hash digest
SHA256 e75b00b31cf2b92614d147d18f4a2efea75b405f87086a9ab693fd865936379c
MD5 22db5dc5fa766d62e53c36aaaf3b6c24
BLAKE2b-256 557f96d3ba138a7ee50dbe1e7a2c4acaf8d45eec55c3aa869781223bafb9af3f

See more details on using hashes here.

File details

Details for the file ridgeplot-0.1.10-py2.py3-none-any.whl.

File metadata

  • Download URL: ridgeplot-0.1.10-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.10

File hashes

Hashes for ridgeplot-0.1.10-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3a0a7b3bf30fd3df2a8102fe9e6ba7270be18e202b7aa143010192a77ab30156
MD5 5aec8e6320d219943e1ed539b29159bc
BLAKE2b-256 e946782443d8e03a3b93bb833b9df3523d27cc303ac495d8dab7a2d9f921e863

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page