Skip to main content

ggplot for python

Project description

https://secure.travis-ci.org/yhat/ggplot.png?branch=master

{ggplot} from Yhat

read more on our blog

from ggplot import *

ggplot(aes(x='date', y='beef'), data=meat) + \
    geom_point(color='lightblue') + \
    stat_smooth(span=.15, color='black', se=True) + \
    ggtitle("Beef: It's What's for Dinner") + \
    xlab("Date") + \
    ylab("Head of Cattle Slaughtered")
https://raw.github.com/yhat/ggplot/master/ggplot/tests/baseline_images/test_readme_examples/ggplot_demo_beef.png

What is it?

Yes, it’s another port of ggplot2. One of the biggest reasons why I continue to reach for R instead of Python for data analysis is the lack of an easy to use, high level plotting package like ggplot2. I’ve tried other libraries like bokeh and d3py but what I really want is ggplot2.

ggplot is just that. It’s an extremely un-pythonic package for doing exactly what ggplot2 does. The goal of the package is to mimic the ggplot2 API. This makes it super easy for people coming over from R to use, and prevents you from having to re-learn how to plot stuff.

Goals

  • same API as ggplot2 for R

  • never use matplotlib again

  • ability to use both American and British English spellings of aesthetics

  • tight integration with pandas

  • pip installable

Getting Started

Dependencies

This package depends on the following packages, although they should be automatically installed if you use pip:

  • matplotlib

  • pandas

  • numpy

  • scipy

  • statsmodels

  • patsy

Installation

Installing ggplot is really easy. Just use pip!

$ pip install ggplot

Loading ggplot

# run an IPython shell (or don't)
$ ipython
In [1]: from ggplot import *

That’s it! You’re ready to go!

Examples

meat_lng = pd.melt(meat[['date', 'beef', 'pork', 'broilers']], id_vars='date')
ggplot(aes(x='date', y='value', colour='variable'), data=meat_lng) + \
    geom_point() + \
    stat_smooth(color='red')
https://raw.github.com/yhat/ggplot/master/ggplot/tests/baseline_images/test_readme_examples/ggplot_meat.png

geom_point

from ggplot import *
ggplot(diamonds, aes('carat', 'price')) + \
    geom_point(alpha=1/20.) + \
    ylim(0, 20000)
https://raw.github.com/yhat/ggplot/master/ggplot/tests/baseline_images/test_readme_examples/diamonds_geom_point_alpha.png

geom_histogram

p = ggplot(aes(x='carat'), data=diamonds)
p + geom_histogram() + ggtitle("Histogram of Diamond Carats") + labs("Carats", "Freq")
https://raw.github.com/yhat/ggplot/master/ggplot/tests/baseline_images/test_readme_examples/diamonds_carat_hist.png

geom_density

ggplot(diamonds, aes(x='price', color='cut')) + \
    geom_density()
https://raw.github.com/yhat/ggplot/master/ggplot/tests/baseline_images/test_readme_examples/geom_density_example.png
meat_lng = pd.melt(meat[['date', 'beef', 'broilers', 'pork']], id_vars=['date'])
p = ggplot(aes(x='value', colour='variable', fill=True, alpha=0.3), data=meat_lng)
p + geom_density()
https://raw.github.com/yhat/ggplot/master/ggplot/tests/baseline_images/test_readme_examples/density_with_fill.png

geom_bar

p = ggplot(mtcars, aes('factor(cyl)'))
p + geom_bar()
https://raw.github.com/yhat/ggplot/master/ggplot/tests/baseline_images/test_readme_examples/mtcars_geom_bar_cyl.png

TODO

The list is long, but distinguished. We’re looking for contributors! Email greg at yhathq.com for more info. For getting started with contributing, check out these docs

https://ga-beacon.appspot.com/UA-46996803-1/ggplot/README.md

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

ggplot-0.4.7.tar.gz (3.8 MB view details)

Uploaded Source

Built Distribution

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

ggplot-0.4.7-py2.7.egg (4.0 MB view details)

Uploaded Egg

File details

Details for the file ggplot-0.4.7.tar.gz.

File metadata

  • Download URL: ggplot-0.4.7.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ggplot-0.4.7.tar.gz
Algorithm Hash digest
SHA256 31056e8bc2853621cc2acf6f99cfe0e60b5b35ec6edd6ebf911caa2a9e223801
MD5 04f67a57dae2369abfaf27d4dd958bcb
BLAKE2b-256 9e00cd99d185f33d18d6c46a4c0b7998a59cef57890c96e47c6dd27656d313e7

See more details on using hashes here.

File details

Details for the file ggplot-0.4.7-py2.7.egg.

File metadata

  • Download URL: ggplot-0.4.7-py2.7.egg
  • Upload date:
  • Size: 4.0 MB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ggplot-0.4.7-py2.7.egg
Algorithm Hash digest
SHA256 fa5f1d20053118dd7ccbdf7a6105c3c2ec3556f488ebd8454e7c38d573ec9b59
MD5 fe7f1229a8ba06dafe4d8896ff707cda
BLAKE2b-256 d2e3a6c2c74f462106ded78ff5feb2c9ff15534d1f4a8fe87bac56c4abd99c0c

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