unipy.plots.boxplot module

Complexed Plotting Toolkit.

unipy.plots.boxplot.point_boxplot(data, groupby=None, value=None, rot=90, spread=0.2, dot_size=15.0, dot_color='b', dot_alpha=0.2, figsize=12, 9, *args, **kwargs)[source]

Boxplot with points.

Draw boxplots by given keys(groupby, value).

Parameters
  • data (pandas.DataFrame) – a dataset.

  • groupby (str or list-like (default: None)) – A key column to separate. (X-axis, categorical) When str, it should be a column name to groupby. When list-like, it contains a column name to groupby.

  • value (str or list-like (default: None)) – A key column to get values. (Y-axis, numerical) When str, it should be a column name of values. When list-like, it contains a column name of values.

  • rot (int (default: 90)) – A rotation angle to show X-axis labels.

  • spread (float (default: .2)) – A spread ratio of points. The bigger, the pointing distribution width are broader.

  • dot_size (float (default: 15.)) – A size of each points.

  • dot_color (int (default: 'b')) – A color name of each points.

  • dot_alpha (float (default: .2)) – A transparency value of each points.

Returns

  • matplotlib.figure.Figure – A plot figure.

  • Exceptions

  • ———-

  • AssertionError – It is raised when two or more names are given to groupby or value.

See also

pandas.DataFrame.boxplot matplotlib.pyplot

Examples

>>> import unipy.dataset.api as dm
>>> from unipy.plots import point_boxplot
>>> dm.init()
>>> data = dm.load('iris')
Dataset : iris
>>> tmp = point_boxplot(data, groupby='species', value='sepal_length')
unipy.plots.boxplot.point_boxplot_axis(data, groupby=None, value=None, rot=90, spread=0.2, dot_size=15.0, dot_color='b', dot_alpha=0.2, share_yrange=True, figsize=12, 9, *args, **kwargs)[source]

Boxplot with points, horizontally seperated.

Draw boxplots by given keys(groupby, value).

Parameters
  • data (pandas.DataFrame) – a dataset.

  • groupby (str or list-like (default: None)) – A key column to separate. (X-axis, categorical) When str, it should be a column name to groupby. When list-like, it contains a column name to groupby.

  • value (str or list-like (default: None)) – A key column to get values. (Y-axis, numerical) When str, it should be a column name of values. When list-like, it contains a column name of values.

  • rot (int (default: 90)) – A rotation angle to show X-axis labels.

  • spread (float (default: .2)) – A spread ratio of points. The bigger, the pointing distribution width are broader.

  • dot_size (float (default: 15.)) – A size of each points.

  • dot_color (int (default: 'b')) – A color name of each points.

  • dot_alpha (float (default: .2)) – A transparency value of each points.

  • share_yrange (Boolean (defalut: True)) – False then each Y-axis limit of boxplots will draw independent.

Returns

  • matplotlib.figure.Figure – A plot figure.

  • Exceptions

  • ———-

  • AssertionError – It is raised when two or more names are given to groupby or value.

See also

pandas.DataFrame.boxplot matplotlib.pyplot

Examples

>>> import unipy.dataset.api as dm
>>> from unipy.plots import point_boxplot_axis
>>> dm.init()
>>> data = dm.load('iris')
Dataset : iris
>>> tmp = point_boxplot_axis(data,
...                          groupby='species',
...                          value='sepal_length',
...                          share_yrange=True)
unipy.plots.boxplot.mosaic_plot(data, groupby=None, col_list=None, show_values=True, rot=90, width=0.9, figsize=12, 9, *args, **kwargs)[source]

Mosaic Plot via Stacked bar plots.

Draw plots by given keys(groupby, value).

Parameters
  • data (pandas.DataFrame) – a dataset.

  • groupby (str or list-like (default: None)) – A key column to separate. (X-axis, categorical) When str, it should be a column name to groupby. When list-like, it contains a column name to groupby.

  • col_list (str or list-like (default: None)) – A key column to get values. (Y-axis, numerical) When str, it should be column names of values. When list-like, it contains column names of values.

  • rot (int (default: 90)) – A rotation angle to show X-axis labels.

  • show_values (boolean (default: True)) – Choose If n is annotated.

Returns

  • matplotlib.figure.Figure – A plot figure.

  • Exceptions

  • ———-

  • AssertionError – It is raised when two or more names are given to groupby or value.

See also

pandas.DataFrame.barplot matplotlib.pyplot

Examples

>>> import unipy.dataset.api as dm
>>> from unipy.plots import mosaic_plot
>>> dm.init()
>>> data = dm.load('adult')
Dataset : iris
>>> tmp = mosaic_plot(data, groupby='native_country',
... col_list=['workclass', 'education'])