psynlig.histogram

A module for generating histograms plots of variables.

psynlig.histogram._histogram2d_contour(axi, data, xvar, yvar, show_contour, counts, xedges, yedges, **kwargs)[source]

Add a contour plot to the given axis.

Parameters
  • axi (object like matplotlib.axes.Axes) – The axis we will add the plot to.

  • data (object like pandas.core.frame.DataFrame) – The data we are plotting, here it is assume that we can select the values given by xvar and yvar.

  • xvar (string) – The variable to use as the x-variable.

  • yvar (string) – The variable to use as the y-variable.

  • show_contour (boolean or string or None) – The type of contour plot we will make. A value of filled will give a filled contour, anything else gives just the lines.

  • counts (object like numpy.ndarray or None) – The data points we will use to create the contour plot from.

  • xedges (object like numpy.ndarray or None) – X-values for the binning used to obtain counts.

  • yedges (object like numpy.ndarray or None) – Y-values for the binning used to obtain counts.

  • kwargs (dict, optional) – Additional settings for the contour plot.

psynlig.histogram._histogram2d_style(axi, *spines, xlim=None, ylim=None)[source]

Style the given axis for 1D histograms.

Parameters
  • axi (object like matplotlib.axes.Axes) – The axis we will style.

  • spines (list of strings) – The spines we will hide.

  • xlim (tuple of floats, optional) – The limits for the x-axis.

  • ylim (tuple of floats, optional) – The limits for the y-axis.

psynlig.histogram.histogram1d(axi, data, variable, class_data=None, class_names=None, cmap_class=None, **kwargs)[source]

Add a single histogram to the given axis.

Parameters
  • axi (object like matplotlib.axes.Axes) – The axis we will add the histogram to.

  • data (object like pandas.core.frame.DataFrame) – The data we are plotting.

  • variable (list of strings) – The variable we are going to plot for.

  • class_data (object like pandas.core.series.Series, optional) – Class information for the points (if available).

  • class_names (dict of strings, optional) – A mapping from the class data to labels/names.

  • cmap_class (string or object like matplotlib.colors.Colormap, optional) – A color map to use for classes.

  • kwargs (dict, optional) – Additional settings for the plotting.

psynlig.histogram.histogram2d(data, xvar, yvar, class_data=None, class_names=None, show_hist=True, show_scatter=False, show_contour=False, cmap_class=None, **kwargs)[source]

Generate a 2D histogram.

Parameters
  • data (object like pandas.core.frame.DataFrame) – The data we are plotting, here it is assume that we can select the values given by xvar and yvar.

  • xvar (string) – The variable to use as the x-variable.

  • yvar (string) – The variable to use as the y-variable.

  • class_data (object like pandas.core.series.Series, optional) – Class information for the points (if available).

  • class_names (dict of strings, optional) – A mapping from the class data to labels/names.

  • show_hist (boolean, optional, optional) – If True, we will display the 2D histogram.

  • show_scatter (boolean, optional) – If True, we will show the raw data used to obtain the histogram.

  • show_contour (boolean or string, optional) – If different from False, we will add a contour plot. If show_contour = filled we will then plot filled contours, otherwise, we will plot just the contour lines.

  • cmap_class (string or object like matplotlib.colors.Colormap, optional) – A color map to use for classes.

  • kwargs (dict of dicts, optional) – Additional settings for the plot elements. It may contain the following keys:

    • histogram2d with settings for the 2D histogram plot.

    • histogram1d with settings for the 1D histogram plots.

    • scatter with settings for the plotting of the raw data.

    • contour with settings for the contour plot.

psynlig.histogram.histograms(data, variables, class_data=None, class_names=None, nrows=None, ncols=None, sharex=False, sharey=False, cmap_class=None, **kwargs)[source]

Generate histogram(s) from the given data.

Parameters
  • data (object like pandas.core.frame.DataFrame) – The data we are creating histograms for.

  • variables (list of strings, optional) – The variables we are going to plot for.

  • class_data (object like pandas.core.series.Series, optional) – Class information for the points (if available).

  • class_names (dict of strings, optional) – A mapping from the class data to labels/names.

  • nrows (integer, optional) – Number of rows to use when plotting several histograms in the same figure.

  • ncols (integer, optional) – Number of columns to use when plotting several histograms in the same figure.

  • sharex (boolean, optional) – If True, the histograms will share the x-axis.

  • sharey (boolean, optional) – If True, the histograms will share the y-axis.

  • cmap_class (string or object like matplotlib.colors.Colormap, optional) – A color map to use for classes (if any).

  • kwargs (dict, optional) – Additional settings for the plotting.

Returns