doeasyeda.create_scatter_plot

Module Contents

Functions

create_scatter_plot(df, x_col, y_col[, size, color, ...])

Creates a scatter plot using Altair with customizable options.

exception doeasyeda.create_scatter_plot.DoEasyEDAException(message, original_exception)[source]

Bases: Exception

Common base class for all non-exit exceptions.

doeasyeda.create_scatter_plot.create_scatter_plot(df, x_col, y_col, size=60, color=None, title=None, x_title=None, y_title=None, tooltip=None, interactive=False, width=None, height=None)[source]

Creates a scatter plot using Altair with customizable options.

Parameters:
  • df (pd.DataFrame) – Dataframe containing the data for the scatter plot.

  • x_col (str) – The column name to be used for the x-axis.

  • y_col (str) – The column name to be used for the y-axis.

  • size (int, optional) – The size of the scatter plot markers (default is 60).

  • color (str, optional) – The column name to be used for color encoding (default is None).

  • title (str, optional) – The title of the scatter plot (default is None).

  • x_title (str, optional) – The title for the x-axis (default is None).

  • y_title (str, optional) – The title for the y-axis (default is None).

  • tooltip (list of str, optional) – List of column names to be used for tooltips (default is None).

  • interactive (bool, optional) – If True, enables interactive features like zooming and panning (default is False).

  • width (int, optional) – The width of the chart (default is None).

  • height (int, optional) – The height of the chart (default is None).

Returns:

An Altair Chart object representing the scatter plot.

Return type:

alt.Chart

Example

>>> data = pd.DataFrame({'gdpPercap': [1000, 2000, 3000, 4000],
...                      'lifeExp': [70, 80, 60, 65],
...                      'continent': ['Asia', 'Europe', 'Africa', 'Americas']})
>>> create_scatter_plot(data, 'gdpPercap', 'lifeExp', size=60, color='continent',
...                     title='Life Expectancy vs GDP Per Capita by Continent',
...                     x_title='GDP Per Capita', y_title='Life Expectancy', interactive=True)