ggplot for python

65
ggplot for python Greg Lamp

description

Making basic, good-looking plots in Python is tough. Matplotlib gives you great control, but at the expense of being very detailed. The rise of pandas has made Python the go-to language for data wrangling and munging but many people are still reluctant to leave R because of its outstanding data viz packages. ggplot is a port of the popular R package ggplot2. It provides a high level grammar that allow users to quickly and easily make good looking plots. So say good-bye to matplotlib, and hello to ggplot as your everyday Python plotting library!

Transcript of ggplot for python

Page 1: ggplot for python

ggplot for pythonGreg Lamp

Page 2: ggplot for python

ggplot

● What is it?● Alternatives● How it works● Why should I use it?● Tutorial

Page 3: ggplot for python

Here I am on the Internet.

Founder/CTO @ Yhat

Hi, I’m Greg!

Page 4: ggplot for python

What is ggplot?

Page 5: ggplot for python
Page 6: ggplot for python

DSL for graphics

Page 7: ggplot for python

DSL for graphics

scatterplot

histogram

labels

color

shape

Page 8: ggplot for python

What about matplotlib?

Page 9: ggplot for python
Page 10: ggplot for python

matplotlib

syntax, api, default themes, learning curve

Page 11: ggplot for python

matplotlib

maturity, ipython, customization, community

syntax, api, default themes, learning curve

Page 12: ggplot for python

“Facet all things”

www.gregreda.com

Page 13: ggplot for python
Page 14: ggplot for python

matplotlib ggplot

Page 15: ggplot for python

What about d3.js?

Page 16: ggplot for python

d3.js

Page 17: ggplot for python

ggplot

Page 18: ggplot for python

ggplot d3.js

Page 19: ggplot for python

How it works

Page 20: ggplot for python

Format

Page 21: ggplot for python

ggplot

Page 22: ggplot for python
Page 23: ggplot for python

data frame

Page 24: ggplot for python

“aesthetics”

Page 25: ggplot for python

Aesthetics

Page 26: ggplot for python
Page 27: ggplot for python
Page 28: ggplot for python
Page 29: ggplot for python

color

Page 30: ggplot for python

shape

Page 31: ggplot for python

size

Page 32: ggplot for python

...fill, alpha, slope, intercept, ymin,

ymax, ...

Page 33: ggplot for python

Geoms, Stats, & Scales

Page 34: ggplot for python

geom_point

Page 35: ggplot for python

geom_area

Page 36: ggplot for python

...there are many

Page 37: ggplot for python

stat_smooth

Page 38: ggplot for python

...there are a few

Page 39: ggplot for python

scale_color_brewer

Page 40: ggplot for python

scale_color_gradient

Page 41: ggplot for python

...there are many

Page 42: ggplot for python

Layers

Page 43: ggplot for python
Page 44: ggplot for python

+

Page 45: ggplot for python

+ +

Page 46: ggplot for python

+ +ggplot() geom_point() stat_smooth()+ +

Page 47: ggplot for python

ggplot() + geom_point() + stat_smooth()

Page 48: ggplot for python

Why is this good?

Page 49: ggplot for python

Makes “reasonable assumptions”

Page 50: ggplot for python

not real colors

Page 51: ggplot for python

matplotlib freaks

Page 52: ggplot for python

still not real colors

...but i can guess what you mean

Page 53: ggplot for python
Page 54: ggplot for python

Concise yet expressive

Page 55: ggplot for python
Page 56: ggplot for python
Page 57: ggplot for python
Page 58: ggplot for python

Looks pretty good(and is easy to customize)

Page 59: ggplot for python
Page 60: ggplot for python

Seaborngithub.com/mwaskom/seaborn

Page 61: ggplot for python

Tutorial

Page 63: ggplot for python

What’s next

Page 64: ggplot for python

http://ggplot.yhathq.com

Page 65: ggplot for python

Thanks!@theglamp

[email protected]