pecos.graphics module

The graphics module contains functions to generate scatter, time series, and heatmap plots for reports.

pecos.graphics.plot_scatter(x, y, xaxis_min=None, xaxis_max=None, yaxis_min=None, yaxis_max=None, title=None, figsize=(7.0, 3.0))[source]

Create a scatter plot. If x and y have the same number of columns, then the columns of x are plotted against the corresponding columns of y, in order. If x (or y) has 1 column, then that column of data is plotted against all the columns in y (or x).

Parameters:
  • x (pandas DataFrame) – X data

  • y (pandas DataFrame) – Y data

  • xaxis_min (float, optional) – X-axis minimum, default = None (autoscale)

  • xaxis_max (float, optional) – X-axis maximum, default = None (autoscale)

  • yaxis_min (float, optional) – Y-axis minimum, default = None (autoscale)

  • yaxis_max (float, optional) – Y-axis maximum, default = None (autoscale)

  • title (string, optional) – Title, default = None

  • figsize (tuple, optional) – Figure size, default = (7.0, 3.0)

pecos.graphics.plot_timeseries(data, tfilter=None, test_results_group=None, xaxis_min=None, xaxis_max=None, yaxis_min=None, yaxis_max=None, title=None, figsize=(7.0, 3.0), date_formatter=None)[source]

Create a time series plot using each column in the DataFrame.

Parameters:
  • data (pandas DataFrame or Series) – Data, indexed by time

  • tfilter (pandas Series, optional) – Boolean values used to include time filter in the plot, default = None

  • test_results_group (pandas DataFrame, optional) – Test results for the data default = None

  • xaxis_min (float, optional) – X-axis minimum, default = None (autoscale)

  • xaxis_max (float, optional) – X-axis maximum, default = None (autoscale)

  • yaxis_min (float, optional) – Y-axis minimum, default = None (autoscale)

  • yaxis_max (float, optional) – Y-axis maximum, default = None (autoscale)

  • title (string, optional) – Title, default = None

  • figsize (tuple, optional) – Figure size, default = (7.0, 3.0)

  • date_formatter (string, optional) – Date formatter used on the x axis, for example, “%m-%d”. Default = None

pecos.graphics.plot_interactive_timeseries(data, xaxis_min=None, xaxis_max=None, yaxis_min=None, yaxis_max=None, title=None, filename=None, auto_open=True)[source]

Create a basic interactive time series graphic using plotly. Many more options are available, see https://plot.ly for more details.

Parameters:
  • data (pandas DataFrame) – Data, indexed by time

  • xaxis_min (float, optional) – X-axis minimum, default = None (autoscale)

  • xaxis_max (float, optional) – X-axis maximum, default = None (autoscale)

  • yaxis_min (float, optional) – Y-axis minimum, default = None (autoscale)

  • yaxis_max (float, optional) – Y-axis maximum, default = None (autoscale)

  • title (string, optional) – Title, default = None

  • filename (string, optional) – HTML file name, default = None (file will be named temp-plot.html)

  • auto_open (boolean, optional) – Flag indicating if HTML graphic is opened, default = True

pecos.graphics.plot_heatmap(data, colors=None, nColors=12, cmap=None, vmin=None, vmax=None, show_axis=False, title=None, figsize=(5.0, 5.0))[source]

Create a heatmap. Default color scheme is red to yellow to green with 12 colors. This function can be used to generate dashboards with simple color indicators in each cell (to remove borders use bbox_inches=’tight’ and pad_inches=0 when saving the image).

Parameters:
  • data (pandas DataFrame, pandas Series, or numpy array) – Data

  • colors (list or None, optional) – List of colors, colors can be specified in any way understandable by matplotlib.colors.ColorConverter.to_rgb(). If None, colors transitions from red to yellow to green.

  • num_colors (int, optional) – Number of colors in the colormap, default = 12

  • cmap (string, optional) – Colormap, default = None. Overrides colors and num_colors listed above.

  • vmin (float, optional) – Colomap minimum, default = None (autoscale)

  • vmax (float, optional) – Colomap maximum, default = None (autoscale)

  • title (string, optional) – Title, default = None

  • figsize (tuple, optional) – Figure size, default = (5.0, 5.0)

pecos.graphics.plot_doy_heatmap(data, cmap='nipy_spectral', vmin=None, vmax=None, overlay=None, title=None, figsize=(7.0, 3.0))[source]

Create a day-of-year (X-axis) vs. time-of-day (Y-axis) heatmap.

Parameters:
  • data (pandas DataFrame or pandas Series) – Data (single column), indexed by time

  • cmap (string, optional) – Colomap, default = nipy_spectral

  • vmin (float, optional) – Colomap minimum, default = None (autoscale)

  • vmax (float, optional) – Colomap maximum, default = None (autoscale)

  • overlay (pandas DataFrame, optional) – Data to overlay on the heatmap. Time index should be in day-of-year (X-axis) Values should be in time-of-day in minutes (Y-axis)

  • title (string, optional) – Title, default = None

  • figsize (tuple, optional) – Figure size, default = (7.0, 3.0)

pecos.graphics.plot_test_results(data, test_results, tfilter=None, image_format='png', dpi=500, figsize=(7.0, 3.0), date_formatter=None, filename_root='test_results')[source]

Create test results graphics which highlight data points that failed a quality control test.

Parameters:
  • data (pandas DataFrame) – Data, indexed by time (pm.data)

  • test_results (pandas DataFrame) – Summary of the quality control test results (pm.test_results)

  • tfilter (pandas Series, optional) – Boolean values used to include time filter in the plot, default = None

  • image_format (string , optional) – Image format, default = ‘png’

  • dpi (int, optional) – DPI resolution, default = 500

  • figsize (tuple, optional) – Figure size, default = (7.0,3.0)

  • date_formatter (string, optional) – Date formatter used on the x axis, for example, “%m-%d”. Default = None

  • filename_root (string, optional) – File name root. If the full path is not provided, files are saved into the current working directory. Each graphic filename is appended with an integer. For example, filename_root = ‘test’ will generate a files named ‘test0.png’, ‘test1.png’, etc. By default, the filename root is ‘test_results’

Returns:

A list of file names