votesim.plots

Function Summary

auto_num_fmt(self, number[, sf])

bar(x, y[, data, fmt])

Custom bar plot with values on bars

heat_pivot(data, x, y, hue[, func, xbin, …])

heatmap(x, y, hue, data[, func, xbin, ybin, …])

Custom heatmap for either categorical or numeric data.

show_values_on_bars(axs[, height, fmt])

Put labels on seaborn bar chart from stack overflow https://stackoverflow.com/questions/43214978/seaborn-barplot-displaying-values

subplot_2row(**kwargs)

subplot_2set(**kwargs)

subplot_4set(**kwargs)

test_2row()

test_2set()

test_bar()

test_heat_category()

test_heat_continuous()

test_heat_mixed()

vset()

Set votesim preferred matplotlib global options

Module Functions

auto_num_fmt

votesim.plots.auto_num_fmt(self, number, sf=3)

bar

votesim.plots.bar(x, y, data=None, fmt='g', **kwargs)

Custom bar plot with values on bars

Parameters
  • x (str) – data column name for x-axis

  • y (str) – data column name for y-axis

  • array, or list of arrays, optional (dataDataFrame,) – Dataset for plotting.

Returns

ax – Returns the Axes object with the plot drawn onto it.

Return type

matplotlib Axes

heat_pivot

votesim.plots.heat_pivot(data, x, y, hue, func='mean', xbin=None, ybin=None, sort=True)

heatmap

votesim.plots.heatmap(x, y, hue, data, func='mean', xbin=None, ybin=None, annot=True, fmt='.1f', xfmt='g', yfmt='g', cbar=False, linewidths=0.5, cmap='viridis_r', sort=True, xsortkey=None, ysortkey=None, **kwargs)

Custom heatmap for either categorical or numeric data.

Parameters
  • x (str) – column name of data plotted on x-axis

  • y (str) – Column name of data plotted on y-axis

  • hue (str) – Column name of data values plotted on heatmap.

  • data (Pandas DataFrame) – Data used in plot

  • func (str or function) –

    aggregation function for data.agg, for example

    • ’min’, ‘mean’, ‘max’, ‘sum’

    • np.mean

  • ybin (xbin,) –

    If x or y is not categorical data, bin

    • None (default) – if x or y is categorical data, do nothing.

    • int – Set to number of bins to divide data using pandas.cut

    • array – User defined bins to divide data using pandas.cut

  • yfmt (xfmt,) – Formatting string for x and y axes, default ‘.2f’.

  • sort (bool) – Sort the results by their average across the x-axis. Default True.

  • **kwargs – Additional arguments passed into seaborn.heatmap.

Returns

  • ax (matplotlib Axes) – Axes object with the heatmap.

  • dfp (pandas DataFrame) – Pivot table used to construct heatmap

show_values_on_bars

votesim.plots.show_values_on_bars(axs, height=0.2, fmt='g')

Put labels on seaborn bar chart from stack overflow https://stackoverflow.com/questions/43214978/seaborn-barplot-displaying-values

subplot_2row

votesim.plots.subplot_2row(**kwargs)

subplot_2set

votesim.plots.subplot_2set(**kwargs)

subplot_4set

votesim.plots.subplot_4set(**kwargs)

test_2row

votesim.plots.test_2row()

test_2set

votesim.plots.test_2set()

test_bar

votesim.plots.test_bar()

test_heat_category

votesim.plots.test_heat_category()

test_heat_continuous

votesim.plots.test_heat_continuous()

test_heat_mixed

votesim.plots.test_heat_mixed()

vset

votesim.plots.vset()

Set votesim preferred matplotlib global options