magmaviz.scatterplot

Module Contents

Functions

scatterplot(df, x, y, c='', t='', o=0.5, s=50, xtitle='', ytitle='', ctitle='', xzero=False, yzero=False, shapes=True)

Plot a scatterplot on the dataframe with the magma color scheme.

magmaviz.scatterplot.scatterplot(df, x, y, c='', t='', o=0.5, s=50, xtitle='', ytitle='', ctitle='', xzero=False, yzero=False, shapes=True)[source]

Plot a scatterplot on the dataframe with the magma color scheme.

Parameters
  • df (dataframe) – Dataframe containing the numerical features x and y

  • x (string) – Column-name of the numerical variable to be plotted on the x-axis

  • y (string) – Column-name of the numerical variable to be plotted on the y-axis

  • c (string) – Column-name of the categorical variable to color-code the data points Default value is blank for cases when there is no categorical column

  • t (string) – Title of the plot. Default value is blank. If not provided, title will be computed based on x, y and/or c

  • o (float) – Opacity of the data points Default value is 0.5

  • s (integer) – Size of the data points Default value is 50

  • xtitle (string) – Title of the x-axis. Default value is blank. If not provided, title will be proper case of the x axis column

  • ytitle (string) – Title of the y-axis. Default value is blank. If not provided, title will be proper case of the y axis column

  • ctitle (string) – Title of the color legend. Default value is blank. If not provided, title will be proper case of the color column

  • xzero (boolean) – Scale the x-axis to start from 0 by specifying True Default value is set to False

  • yzero (boolean) – Scale the y-axis to start from 0 by specifying True Default value is set to False

  • shapes (boolean) – Assign the color column to the shape attribute of the plot if True Default value is set to True

Returns

Scatterplot between the numerical variables x and y

Return type

altair.vegalite.v4.api.Chart

Example

>>> from magmaviz.scatterplot import scatterplot
>>> from vega_datasets import data
>>> scatterplot(data.iris(), "sepalLength", "sepalWidth", "species",
                "Iris Sepal Length vs Sepal Width across Species",
                1.0, 50, "Sepal Length", "Sepal Width", "", False, False, True)