mypythontools.plots module — mypythontools 24-08-2021 documentation

# mypythontools.plots module

Plot data. There is only one main function plot. Check it’s documentation for how to use it.

mypythontools.plots.plot(complete_dataframe, plot_type='plotly', plot_name='Plot', legend=True, highlighted_column='', surrounded_column='', grey_area=False, save=False, plot_return=False, show=True)

  Plots the data. Plotly or matplotlib can be used. It is possible to highlite two columns with different formating. It is usually used for time series visualization, but it can be used for different use case of course.

  Parameters

    - complete_dataframe (pd.DataFrame) – Data to be plotted.

    - plot_type (str, optional) – ‘plotly’ or ‘matplotlib’. Defaults to “plotly”.

    - legend (bool, optional) – Whether display legend or not. Defaults to True.

    - highlighted_column (str, optional) – Column name that will be formatted differently (blue). Can be empty. Defaults to “”.

    - surrounded_column (str, optional) – Column name that will be formatted differently (black, wider). And is surrounded by grey_area. Can be empty (if grey_area is False). Defaults to “”.

    - grey_area ((bool, list[str])), optional) – Whether to show grey area surrounding the surrounded_column. Can be False, or list of [‘lower_bound_column’, ‘upper_bound_column’]. Both columns has to be in complete_dataframe. Defaults to False.

    - save ((False, str), optional) – Whether save the plot. If False or “”, do not save, if path as str, save to defined path, if “DESKTOP” save to desktop. Defaults to “”.

    - plot_return ((bool, str), optional) – If ‘div’, return html div with plot as string. If False, just plot and do not return. Defaults to False.

    - show (bool, optional) – Can be evaluated, but not shown (testing reasons). Defaults to True.

  Returns

    Only if plot_return == ‘div

  Return type

    str

  Examples

  Plot dataframe with

      >>> import pandas as pd
      >>> plot(pd.DataFrame([[None, None, 1], [None, None, 2], [3, 3, 6], [3, 2.5, 4]]), show=False)  # Show False just for testing reasons