Exemple #1
0
def plot_any_value_by_year(values, dates, show=True, outjson=None, outimg=None):
    """

    """
    # Build data frame
    df = pd.DataFrame(values, index=dates)

    # Build Vincent plot
    plot = StackedBar(df, height=600, width=600)

    # Configure axes
    plot.scales['y'].domain = [0, 1]

    # Optionally display
    if show:
        plot.display()

    # Optionally save
    save_plot(plot, outjson=outjson, outimg=outimg)

    return plot
Exemple #2
0
def plot_values_by_year(values, dates, labels, show=False, outjson=None, outimg=None):
    """Plot values (counts or proportions) by year.

    """
    # Build data frame
    df = pd.DataFrame(values, index=dates, columns=labels)

    # Build Vincent plot
    plot = StackedBar(df, height=600, width=600)

    # Configure colors
    plot.colors(brew='Set1')

    # Configure legends
    plot.legends.append(Legend(values=labels[::-1], fill='color'))
    plot.legends[0].properties = LegendProperties(
        size=ValueRef(value=18)
    )

    # Configure axes
    plot.axes[0].properties = AxisProperties(labels=PropertySet(
        angle=ValueRef(value=-45),
        dx=ValueRef(value=-20),
        font_size=ValueRef(value=18)
    ))
    plot.scales['y'].domain = [0, 1]

    # Optionally display
    if show:
        plot.display()

    # Optionally save
    save_plot(plot, outjson, outimg)

    return plot