bigframes.pandas.DataFrame.area#

DataFrame.area(x: Hashable | None = None, y: Hashable | None = None, stacked: bool = True, **kwargs)[source]#

Draw a stacked area plot. An area plot displays quantitative data visually.

This function calls pandas.plot to generate a plot with a random sample of items. For consistent results, the random sampling is reproducible. Use the sampling_random_state parameter to modify the sampling seed.

Examples:

Draw an area plot based on basic business metrics:

>>> import bigframes.pandas as bpd
>>> df = bpd.DataFrame(
...     {
...         'sales': [3, 2, 3, 9, 10, 6],
...         'signups': [5, 5, 6, 12, 14, 13],
...         'visits': [20, 42, 28, 62, 81, 50],
...     },
...     index=["01-31", "02-28", "03-31", "04-30", "05-31", "06-30"]
... )
>>> ax = df.plot.area()

Area plots are stacked by default. To produce an unstacked plot, pass stacked=False:

>>> ax = df.plot.area(stacked=False)

Draw an area plot for a single column:

>>> ax = df.plot.area(y='sales')

Draw with a different x:

>>> df = bpd.DataFrame({
...     'sales': [3, 2, 3],
...     'visits': [20, 42, 28],
...     'day': [1, 2, 3],
... })
>>> ax = df.plot.area(x='day')
Parameters:
  • x (label or position, optional) – Coordinates for the X axis. By default uses the index.

  • y (label or position, optional) – Column to plot. By default uses all columns.

  • stacked (bool, default True) – Area plots are stacked by default. Set to False to create a unstacked plot.

  • sampling_n (int, default 100) – Number of random items for plotting.

  • sampling_random_state (int, default 0) – Seed for random number generator.

  • **kwargs – Additional keyword arguments are documented in DataFrame.plot().

Returns:

Area plot, or array of area plots if subplots is True.

Return type:

matplotlib.axes.Axes or numpy.ndarray