Skip to main content

A package for combining python ggplot visuals

Project description

cowpatch

test and codecov codecov CodeFactor

A package for combining/aranging multiple python ggplot visuals from plotnine. Internally, we leverage SVG objects and descriptions to accomplish it's goals.

Installation

To install the current version of this package, please run

pip install cowpatch

If you would like to experiment with the development version of this package please following the guidelines in the contributing page.

Usage

import cowpatch as cow
import plotnine as p9
import plotnine.data as p9_data
import numpy as np
# creation of some some ggplot objects
g0 = p9.ggplot(p9_data.mpg) +\
    p9.geom_bar(p9.aes(x="hwy")) +\
    p9.labs(title = 'Plot 0')

g1 = p9.ggplot(p9_data.mpg) +\
    p9.geom_point(p9.aes(x="hwy", y = "displ")) +\
    p9.labs(title = 'Plot 1')

g2 = p9.ggplot(p9_data.mpg) +\
    p9.geom_point(p9.aes(x="hwy", y = "displ", color="class")) +\
    p9.labs(title = 'Plot 2')
vis_patch = cow.patch(g0,g1,g2)
vis_patch += cow.layout(design = np.array([[0,1],
                                           [0,2]]),
                        rel_heights = [1,2])
vis_patch.show(width = 11, height = 7)

cowpatch example

Please see additional documentation pages like "Getting-Started" and the individual pages on different plot arrangement strategies.

Future Goals

This package is currently in development (please feel welcome to contribute, with code, examples, issues, publicity, etc.). We envision a sequence of versions coming out with different added features in each. The order of the features will look something like the following

  • MVP #1: base implimentation (reflecting cowplot and gridExtra functionality, minus labeling and titles)
  • MVP #2: figure labeling and titles and cow.text() objects
  • MVP #3: "Arithmetic of arrangement" (reflecting patchwork)

In addition, we envision the following features coming along in parallel:

  • inseting plots (like seen in cowplot)
  • wrapping of matplotlib, plotnine and seaborn plots to work within the cowpatch framework and within the patchwork framework
  • more complex drawing tools like the R package grid to allow for easy creation of complex features

For the interested reader, a lot of these ideas have been sketched in our notes/ folder as "proof of concepts".

Package Logistics

Background and history

This package's name is a merging of the names of R packages' cowplot and patchwork. It attempts to provide similar plot arrangement and combination tools as gridExtra, cowplot and patchwork for the plotnine's ggplot objects.

This package is not directly related to any of aforementioned packages (including the Wilke Lab, lead by Claus O. Wilke) but naturally stands on the shoulders of the contributions each of the packages made.

This package leverages a SVG backend to create the arangements. This may make the actual package a bit more "hacky" then some may like, but we hope it can still be of use to the community.

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

cowpatch was created by Benjamin LeRoy (benjaminleroy) and Mallory Wang (wangmallory). It is licensed under the terms of the MIT license.

Credits

This python package stands on the shoulders of many open-source tools, cowpatch structure was created with cookiecutter and the py-pkgs-cookiecutter template, the documentation leverages sphinx, and underlying testing leverages pytest, hypothesis and pytest-regression. See the full list of package dependencies on Github.

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

cowpatch-0.1.2.tar.gz (30.1 kB view details)

Uploaded Source

Built Distribution

cowpatch-0.1.2-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

Details for the file cowpatch-0.1.2.tar.gz.

File metadata

  • Download URL: cowpatch-0.1.2.tar.gz
  • Upload date:
  • Size: 30.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.8.13 Darwin/21.6.0

File hashes

Hashes for cowpatch-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5e2a3b72ae9100658782bed7e4d5831e5feb3815ea4906a8461d3ffe3cb4782b
MD5 26a658386460f756b583309df93db54d
BLAKE2b-256 a28811a2fc27b81dab49b494b4e517ba07f2c132400d7e7c1ea28a57739b9924

See more details on using hashes here.

File details

Details for the file cowpatch-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: cowpatch-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 30.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.8.13 Darwin/21.6.0

File hashes

Hashes for cowpatch-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 76d03ec2e6a59606dcaae1e19161b64986c1a9f051642ab367a2e3ab9a894ea5
MD5 b377d1651f5ca6ff9cb8352f49e1602d
BLAKE2b-256 c4aed8a452383eff89fa08b341791de5c94a8fd8adbe84a9f74f95b64fdd3def

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