skip to navigation
skip to content

Not Logged In

ggplot 0.6.8

ggplot for python


{ggplot} from `Yhat <http:"">`__

read more on our
`blog <http:"" posts="" ggplot-for-python.html="">`__


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")

.. figure::
:alt: image

What is it?

Yes, it's another port of
`ggplot2 <https:"" hadley="" 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 <https:"" continuumio="" bokeh="">`__ and
`d3py <https:"" mikedewar="" d3py="">`__ but what I really want is

``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


- same API as ``ggplot2`` for ``R``
- ability to use both American and British English spellings of
- tight integration with `pandas <https:"" pydata="" pandas="">`__
- pip installable

Getting Started


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

- ``matplotlib``
- ``pandas``
- ``numpy``
- ``scipy``
- ``statsmodels``
- ``patsy``


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!



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() + \

.. figure::
:alt: image



from ggplot import *
ggplot(diamonds, aes('carat', 'price')) + \
geom_point(alpha=1/20.) + \
ylim(0, 20000)

.. figure::
:alt: image



p = ggplot(aes(x='carat'), data=diamonds)
p + geom_histogram() + ggtitle("Histogram of Diamond Carats") + labs("Carats", "Freq")

.. figure::
:alt: image



ggplot(diamonds, aes(x='price', color='cut')) + \

.. figure::
:alt: image


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()

.. figure::
:alt: image



p = ggplot(mtcars, aes('factor(cyl)'))
p + geom_bar()

.. figure::
:alt: image


To generate image test data...

In the base dir, run the tests with python, afterwards run
python visual\ (opens a page in a browser) and compare the
plots/ make sure they look as the test intended.

Then copy the missing files from result\_images/test\_whatever/\ *.png
to ggplot/tests/test\_whatever/*.png. Make sure that you DON'T copy
images with filenames ending in *-expected.png, as these are the copies
from ggplot/tests/test\_*/\*.png which the test images get compared to.


`The list is long, but
distinguished. <https:"" yhat="" ggplot="" blob="" master="""">`__
We're looking for contributors! Email greg at for more info.
For getting started with contributing, check out `these
docs <https:"" yhat="" ggplot="" blob="" master="" docs="" contributing.rst="">`__


.. |image| image::
.. |image| image::
File Type Py Version Uploaded on Size
ggplot-0.6.8-py2.7.egg (md5) Python Egg 2.7 2015-08-24 8MB
ggplot-0.6.8.tar.gz (md5) Source 2015-08-24 8MB
  • Downloads (All Versions):
  • 16 downloads in the last day
  • 1449 downloads in the last week
  • 9618 downloads in the last month