In [1]:
from ggplot import *
%matplotlib inline
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 (geom_point) and a line (geom_line) will share x and y, but only a line chart has a linetype aesthetic.
Aesthetics are specific to geoms, but here is a list of all of them:
x : x-axis value. Can be used for continuous (point, line) charts and for discrete (bar, histogram) charts.y : y-axis value. Can be used for continuous charts onlycolor : color of a layer. Can be continuous or discrete. If continuous, this will be given a color gradient between 2 colors.shape : shape of a point. Can be used only with geom_pointsize : size of a point or line. Used to give a relative size for a continuous valuealpha : transparency level of a point. Number between 0 and 1. Only supported for hard coded values.ymin : min value for a vertical line or a range of points. See geom_area, geom_ribbon, geom_vlineymax : max value for a vertical line or a range of points. See geom_area, geom_ribbon, geom_vlinexmin : min value for a horizonal line. Specific to geom_hlinexmax : max value for a horizonal line. Specific to geom_hlineslope : slope of an abline. Specific to geom_ablineintercept : intercept of an abline. Specific to geom_abline
In [2]:
# set the x-axis equal to the `date` column and the y-axis equal to the `beef` column
my_aes = aes(x='date', y='beef')
my_aes
Out[2]:
In [3]:
ggplot(meat, my_aes) + geom_line()
Out[3]:
In [4]:
# normally, aes are defined within the `ggplot` constructor
ggplot(aes(x='carat', y='price'), diamonds) + geom_point()
Out[4]:
In [5]:
# adding in another aesthetic into the mix...
ggplot(aes(x='carat', y='price', color='clarity'), diamonds) + geom_point()
Out[5]:
In [ ]: