Skip to content

Plotting functions

Bar plots

plot.bar()

View Docstring
Signature:
bar(
    data,
    ax,
    stacked,
    group_levels,
    group_spacing,
    bar_width,
    legend,
    cmap,
    reverse_cmap,
    edgecolor,
    linewidth,
    totmarker,
    totmarker_size,
    axis_padding,
    sort_groups,
    sort_xlabels,
    sort_categories,
    xlabel,
    xlabel_fontsize,
    ylabel,
    ylabel_fontsize,
    ticklabels_fontsize,
    xtick_interval,
    grouptitle,
    grouptitle_fontsize,
    grouplabels_fontsize,
    grouplabels_vertical,
    ylim,
    return_group_axes
)

Docstring:
Plots a bar chart from a pandas.DataFrame. Columns are taken as
categories (i.e. color). Bars can be grouped by specifying index levels in
`group_levels`. Remaining index levels are used as x labels.

File: CIBUSmod/utils/plot/bars.py

plot.waterfall()

View Docstring
Signature:
waterfall(
    data,
    ax,
    breaks,
    color_pos,
    color_neg,
    color_line,
    width,
    label,
    label_size,
    **kwargs
)

Docstring:
    (No docstring.)

File: CIBUSmod/utils/plot/bars.py

plot.marimekko()

View Docstring
Signature:
marimekko(
    data,
    ax,
    x_column,
    cmap,
    reverse_cmap,
    edgecolor,
    linewidth,
    axis_padding,
    xlim_pad,
    ylim_pad,
    xlim,
    ylim,
    xlabel,
    xlabel_fontsize,
    ylabel,
    ylabel_fontsize,
    ticklabels_fontsize,
    sort_xcategories,
    sort_categories,
    xcategorylabels_threshold,
    xcategorylabels_wrap,
    xcategorylabels_fontsize,
    xcategorylabels_rotation,
    xcategorylabels_halign
)

Docstring:
    (No docstring.)

File: CIBUSmod/utils/plot/bars.py

Maps

plot.map_from_series()

View Docstring
Signature:
map_from_series(
    ser,
    reg,
    cmap_zero_midpoint,
    **kwargs
)

Docstring:
Parameters
----------
ser : pandas.Series
    A series values to produce the map. Must have 'region' as index
reg : str
    Defines what 'region' refers to ('sko', 'po8', 'kommun' or 'län')
cmap_zero_midpoint : 'shrink', 'shift' or False (default)
    Puts the middle of the color map range on zero
    If 'shrink' the color map's range is shrunk on the postive or negative side
    If 'shift' the colormap's center is shifted but the full range is used on
    both the positive and negative side
**kwargs
    passed on to geopandas.GeoDataFrame.plot()

File: CIBUSmod/utils/plot/maps.py

plot.add_map_layer()

View Docstring
Signature:
add_map_layer(name: str, gdf: gpd.GeoDataFrame)

Docstring:
Add map layer to be available in 'map_from_series' plot function

Parameters
----------
name : str
    Name of layer
gdf : geopandas.GeoDataFrame
    Map layer as GeoDataFrame. Index should be named 'region' and
    have dtype str.

File: CIBUSmod/utils/plot/maps.py

Plot layout

plot.subplots()

View Docstring
Signature:
subplots(
    data,
    index,
    columns,
    plot_fn,
    ncols,
    size,
    title_fontsize,
    **kwargs
)

Docstring:
Function to plot subplots based on a pandas.DataFrame or Series

Parameters
----------
index, columns : (list of) str (default None)
    Index and/or column levels to use for constructing subplot panels.
plot_fn : plot function (default None)
    Must accept a pandas.DataFrame or Series as its first argument and
    the keyword argument 'ax' for supplying a matplotlib Axes object.
    If None, pandas .plot() method is used.
ncols : int (default None)
    Number of columns in subplots.
    If None, ncols is selected automatically.
size : (float, float)
    Size of each subplot panel.
**kwargs
    Keyword arguments that are passed on to plot_fn or .plot() method.

Returns
-------
(Figure, array of Axes)

File: CIBUSmod/utils/plot/subplots.py