Making plots is a very repetetive: draw this line, add these colored points, then add these, etc.
Instead of re-using the same code over and over,
ggplot implements them using a high-level
but very expressive API. The result is less time spent creating your charts, and more time interpreting
what they mean.
ggplot is not a good fit for people trying to make highly customized data visualizations.
While you can make some very intricate, great looking plots,
ggplot sacrafices highly customization
in favor of generall doing "what you'd expect".
ggplot has a symbiotic relationship with
pandas. If you're
planning on using
ggplot, it's best to keep your data in
Think of a
DataFrame as a tabular data object. For example, let's look at the
dataset which ships with
from ggplot import * diamonds.head()
Aesthetics describe how your data will relate to your plots. Some common aesthetics are: x, y, and color. Aesthetics
are specific to the type of plot (or layer) you're adding to your visual. For example, a scatterplot (
and a line (
geom_line)will share x and y, but only a line chart has a
For more information about which
geoms have which aesthetics, see the DOCS SECTION.
ggplot lets you combine or add different types of visualization components (or layers) together. I think
this is easiest to understand with an example.
Start with a blank canvas.
p = ggplot(aes(x='date', y='beef'), data=meat) p
Add some points.
p + geom_point()
Add a line.
p + geom_point() + geom_line()
Add a trendline.
p + geom_point() + geom_line() + stat_smooth(color='blue')
As you can see, you can quite literally add components of your visualization together. For more info on available components, see the DOCS SECTION.