henchman.plotting.scatter

henchman.plotting.scatter(col_1, col_2, cat=None, label=None, aggregate='last', figargs=None)[source]

Creates a scatter plot of two variables. This function allows for the display of two variables with an optional argument to groupby. By default, this allows for the user to see what two variable looks like as grouped by another. A standard example would be to look at the “last” row for a column that’s changing over time.

Parameters:
  • col_1 (pd.Series) – The x-values of the plotted points.
  • col_2 (pd.Series) – The y-values of the plotted points.
  • cat (pd.Series, optional) – A categorical variable to aggregate by.
  • label (pd.Series, optional) – A numeric label to be used in the hovertool.
  • aggregate (str) – The aggregation to use. Options are ‘mean’, ‘last’, ‘sum’, ‘max’ and ‘min’.

Example

If the dataframe X has a columns named amount and quantity.

>>> import henchman.plotting as hplot
>>> plot = hplot.scatter(X['amount'], X['quantity'])
>>> hplot.show(plot)

If you would like to see the amount, quantity pair as aggregated by the month column:

>>> plot2 = hplot.scatter(X['date'], X['amount'], cat=X['month'], aggregate='mean')
>>> hplot.show(plot2)