Skip to main content

A few handy extension plots using seaborn API.

Project description

seabornxt

A few handy extension plots using seaborn API.

To install:

You can install from PyPI as follows:

pip install seabornxt

or you can install it from the GitHub repository:

git clone https://github.com/LeSasse/seabornxt.git
cd seabornxt
pip install .

Use example:

import seaborn as sns
from seabornxt import stripboxplot


def main():
    tips = sns.load_dataset("tips")

    plot = stripboxplot(data=tips, x="day", y="total_bill", hue="smoker")
    fig = plot.get_figure()
    fig.savefig("stripboxplot.pdf")


if __name__ == "__main__":
    main()

Results in:

Alt text

Customise box and strip plots:

You can customise the box and strip plots by passing over the strip_kwargs and box_kwargs dictionaries. The following example displays data points in the same colour as the box plots:

import seaborn as sns
from seabornxt import stripboxplot


def main():
    tips = sns.load_dataset("tips")

    plot = stripboxplot(
        data=tips,
        x="day",
        y="total_bill",
        hue="smoker",
        strip_kwargs={"jitter": True, "alpha": 0.8},
        box_kwargs={"boxprops": {"alpha": 0.4}},
    )
    fig = plot.get_figure()
    fig.savefig("stripboxplot_colors.svg")


if __name__ == "__main__":
    main()

Alt text

The reason for this is that if no strip_kwargs are handed over, I set the color of the points to black for better visibility by default. But if one hands over strip_kwargs, without explicitly specifying a color, the strip plot goes back to the seaborn default color/hue. I prefer black as a default as this is most useful in my use cases.

Another dataset:

import seaborn as sns
from seabornxt import stripboxplot


def main():
    penguins = sns.load_dataset("penguins")
    plot = stripboxplot(
        data=penguins,
        x="sex",
        y="body_mass_g",
        hue="species",
    )
    fig = plot.get_figure()
    fig.savefig("stripboxplot_penguins.svg")


if __name__ == "__main__":
    main()

Alt text

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

seabornxt-0.0.1.dev15.tar.gz (51.1 kB view details)

Uploaded Source

Built Distribution

seabornxt-0.0.1.dev15-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file seabornxt-0.0.1.dev15.tar.gz.

File metadata

  • Download URL: seabornxt-0.0.1.dev15.tar.gz
  • Upload date:
  • Size: 51.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for seabornxt-0.0.1.dev15.tar.gz
Algorithm Hash digest
SHA256 5eeb2c4fa46f322d07a4ba24b989107f8553769af9a7242d1e0d3df29ca94e53
MD5 eebd98cbac3de4b880468567445ed59d
BLAKE2b-256 8a8e9d52dc83eab52d15360b118f7e32356bcad2cd807ec7ca3415a81e232ca8

See more details on using hashes here.

File details

Details for the file seabornxt-0.0.1.dev15-py3-none-any.whl.

File metadata

File hashes

Hashes for seabornxt-0.0.1.dev15-py3-none-any.whl
Algorithm Hash digest
SHA256 20106ff73fa817f133991427873b9da9b1e902e414b9bbffa1a98d6d7a93e3a1
MD5 482764703583a63a728c8123f37a6656
BLAKE2b-256 bb23c858aaa58d04ac5b5c6951d7e006758e1cd77824a7aa1d2097f0b7ca7d6c

See more details on using hashes here.

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