sensortoolkit.plotting._scatter.draw_scatter

draw_scatter(ax, xdata, ydata, param_dict, sensor_stats=None, xlims=None, ylims=None, fontsize=None, detail_fontsize=None, param=None, plot_regression=True, colormap_vals=None, colormap_name=None, **kwargs)[source]

A helper function to draw scatterplots with linear regressions on passed matplotlib axes instance

Parameters
  • ax (Matplotlib axes instance) – The axes object on which the scatter plot is drawn

  • xdata (numpy array or pandas Series) – The x data (reference data)

  • ydata (numpy array or pandas Series) – The y data (sensor data)

  • param_dict (dict) – Dictionary of kwargs to pass to ax.plot

  • sensor_stats (pandas DataFrame) – Dataframe contain regression statistics for single sensor (subset of the full stats_df object)

  • xlims (tuple) – The domain of the graph

  • ylims (tuple) – The range of the graph

  • fontsize (int) – Selects the fontsize of regression statistics

  • detail_fontsize (int or float) – Fontsize for axes tick labels and smaller plotting text elements.

  • param (str) – The name of the parameter for which measurements will be plotted.

  • plot_regression (bool) – True plots linear regression, regression equation, R^2, and RMSE

  • colormap_vals (Dataframe column or none) – Data that are used to set the colormap value.

  • colormap_name (string or none) – The name of the colormap which the scatter plot will be assigned The name of the Matplotlib colormap that will be used when superimposing scatter points with RH values. A full list of colormaps is can be found in the Matplotlib documentation

Keyword Arguments:

Parameters
  • monocolor (str) – A single color (specified in hex) for scatter. Scatter are colored using monocolor if colormap_vals is empty. Defaults to ‘#0048AD’.

  • point_size (float) – The size of the scatter points. Defaults to 20.

  • point_alpha (float) – The transparency of the scatter plots. Defaults to 0.7.

  • plot_aspect (str) – Aspect ratio for scatter plot dimensions. Defaults to ‘equal’.

  • plottext_alpha (float) – The transparency of the text drawn on scatter plots indicating regression statistics. Defaults to 0.8.

  • plottext_size (float) – The size of the text drawn on scatter plots indicating regression statistics as a fraction of the passed fontsize. Defaults to 90% the value of the fontsize.

  • plottext_color (str) – The color of the text drawn on scatter plots indicating regression statistics. Defaults to ‘k’.

  • plottext_xloc (float) – The left-most x-coordinate of the text drawn on scatter plots. Default depends on the value passed to the plottext_postion argument.

  • plottext_yloc (float) – The top-most y-coordinate of the text drawn on scatter plots. Default depends on the value passed to the plottext_postion argument.

  • plottext_xdisplacement (float) – The width displacement between text drawn on scatter plots. Defaults to 0.0.

  • plottext_ydisplacement (float) – The height displacement between rows of text drawn on scatter plots. Defaults to 0.08.

  • plottext_position (str) – Determines position of plot text. Options include ‘upper_left’ or ‘bottom_right’. Defaults to ‘upper_left’ if the slope of the ‘ regression is greater than 1.75, else default is set to ‘bottom_right’.

  • show_trendline (bool) – If true, display the OLS trendline on scatter plots. Defaults to True.

  • show_RMSE (bool) – If true, display the root mean squared error on scatter plots. Defaults to True.

  • show_spearman (bool) – If true, display the spearman correlation on scatterplots. Defaults to False.

  • show_N (bool) – If true, display the number of scatter point pairs displayed on the plot. Defaults to True.

  • show_one_to_one (bool) – If true, display the one-to-one line indicating ideal agreement between independent and depdendent variable. Defaults to True.

  • trendline_xmax (float) – The draw distance (based on the passed x-coordinate) of the OLS trendline. Defaults to 120% the maximum of the independent variable.

  • trendline_color (str) – The color of the trendline. Defaults to ‘k’ (black).

  • trendline_alpha (float) – The transparency of the trendline. Defaults to 0.65.

Returns

Matplotlib axes instance with scatter drawn along with additional elements specified in the kwargs (text, colormap)

Return type

plotobj