Bar Plots

SomeGraphs.Bars.bars_graph Function
function line_graph(;
    [figure_title::Maybe{AbstractString} = nothing,
    bar_axis_title::Maybe{AbstractString} = nothing,
    value_axis_title::Maybe{AbstractString} = nothing,
    bars_values::AbstractVector{<:Real} = Float32[],
    bars_names::Maybe{AbstractVector{<:AbstractString}} = nothing,
    bars_colors::Maybe{AbstractVector{<:AbstractString}} = nothing,
    bars_hovers::Maybe{AbstractVector{<:AbstractString}} = nothing,
    value_bands::BandsData = BandsData(),
    bars_annotations::AbstractVector{AnnotationData} = AnnotationData[],
    configuration::BarsGraphConfiguration = BarsGraphConfiguration()]
)::BarsGraph

Create a BarsGraph by initializing only the BarsGraphData fields (with an optional BarsGraphConfiguration ).

SomeGraphs.Bars.BarsGraphData Type
@kwdef mutable struct BarsGraphData <: AbstractGraphData
    figure_title::Maybe{AbstractString} = nothing
    bar_axis_title::Maybe{AbstractString} = nothing
    value_axis_title::Maybe{AbstractString} = nothing
    bars_colors_title::Maybe{AbstractString} = nothing
    bars_values::AbstractVector{<:Real} = Float32[]
    bars_names::Maybe{AbstractVector{<:AbstractString}} = nothing
    bars_colors::Maybe{Union{AbstractVector{<:AbstractString}, AbstractVector{<:Real}} = nothing
    bars_hovers::Maybe{AbstractVector{<:AbstractString}} = nothing
    value_bands::BandsData = BandsData()
    bars_annotations::AbstractVector{AnnotationData} = AnnotationData[]
end

The data for a graph of a single series of bars.

By default, all the titles are empty. You can specify the overall figure_title as well as the bars_axis_title and value_axis_title for the axes, , and a name for each bar in bars_names . The bars_colors are optional; typically all bars have the same color.

You can even add annotations to the bars.

SomeGraphs.Bars.BarsGraphConfiguration Type
@kwdef mutable struct BarsGraphConfiguration <: AbstractGraphConfiguration
    figure::FigureConfiguration = FigureConfiguration()
    value_axis::AxisConfiguration = AxisConfiguration()
    value_bands::BandsConfiguration = BandsConfiguration()
    values_orientation::ValuesOrientation = VerticalValues
    bars_colors::ColorsConfiguration = ColorsConfiguration()
    bars_gap::Real = 0.02,
    bars_annotations::AnnotationSize = AnnotationSize()
end

Configure a graph for showing a single series of bars.

By default the values are the y axis ( VerticalValues ). You can flip the axes using the values_orientation . You can specify bands for this axis using value_bands . The bars_gap is added between the graps, and is in the usual inconvenient units of fractions of the total graph size. The bars_colors is used to control the color of the bars (if not specified, chosen automatically by Plotly), in combination with the data bar colors (if any).

Examples:

Default (serves as a baseline to compare with when modifying options):

using SomeGraphs
graph = bars_graph(; bars_values = collect(0:10) .* 10)
using PlotlyDocumenter
to_documenter(graph.figure)

Annotations:

using SomeGraphs
graph = bars_graph(; bars_values = collect(0:10) .* 10)
graph.data.bars_annotations = [AnnotationData(; title = "score", values = collect(0:10) .% 3)]
using PlotlyDocumenter
to_documenter(graph.figure)

SomeGraphs.Bars.series_bars_graph Function
function series_bars_graph(;
    [figure_title::Maybe{AbstractString} = nothing,
    bar_axis_title::Maybe{AbstractString} = nothing,
    value_axis_title::Maybe{AbstractString} = nothing,
    series_bars_values::AbstractVector{<:AbstractVector{<:Real}} = Vector{Vector{Float32}}(),
    bars_names::Maybe{AbstractVector{<:AbstractString}} = nothing,
    bars_hovers::Maybe{AbstractVector{<:AbstractString}} = nothing,
    series_names::Maybe{AbstractVector{<:AbstractString}} = nothing,
    series_colors::Maybe{AbstractVector{<:AbstractString}} = nothing,
    series_hovers::Maybe{AbstractVector{<:AbstractString}} = nothing,
    configuration::SeriesBarsGraphConfiguration = SeriesBarsGraphConfiguration()]
)::SeriesBarsGraph

Create a SeriesBarsGraph by initializing only the SeriesBarsGraphData fields (with an optional SeriesBarsGraphConfiguration ).

SomeGraphs.Bars.SeriesBarsGraphData Type
@kwdef mutable struct SeriesBarsGraphData <: AbstractGraphData
    figure_title::Maybe{AbstractString} = nothing
    bar_axis_title::Maybe{AbstractString} = nothing
    value_axis_title::Maybe{AbstractString} = nothing
    series_bars_values::AbstractVector{<:AbstractVector{<:Real}} = Vector{Vector{Float32}}()
    bars_names::Maybe{AbstractVector{<:AbstractString}} = nothing
    bars_hovers::Maybe{AbstractVector{<:AbstractString}} = nothing
    bars_annotations::AbstractVector{AnnotationData} = AnnotationData[]
    series_names::Maybe{AbstractVector{<:AbstractString}} = nothing
    series_colors::Maybe{AbstractVector{<:AbstractString}} = nothing
    series_hovers::Maybe{AbstractVector{<:AbstractString}} = nothing
end

The data for a graph of multiple series of bars.

All the vectors in the series_bars_values must have the same length (the number of bars). The number of entries in bars_names and/or bars_hovers must be the same. The number of entries in series_names , series_colors and/or series_hovers must be the number of series (the number of vectors in series_bars_values ).

All the bars of each series have the same color. If the series_names are specified, then they are used in a legend (or, if using series_gap , as the separate axes titles).

SomeGraphs.Bars.SeriesBarsGraphConfiguration Type
@kwdef mutable struct SeriesBarsGraphConfiguration <: AbstractGraphConfiguration
    figure::FigureConfiguration = FigureConfiguration()
    value_axis::AxisConfiguration = AxisConfiguration()
    values_orientation::ValuesOrientation = VerticalValues
    bars_gap::Maybe{Real} = nothing
    bars_annotations::AnnotationSize = AnnotationSize(),
    series_gap::Maybe{Real} = nothing
    stacking::Maybe{Stacking} = nothing
end

Configure a graph for showing multiple series of bars.

This expands on BarsGraphConfiguration by adding optional stacking for stacking the bars of the different series on top of each other. Alternatively, specifying a series_gap will plot each series in its own separate sub-graph. The series_gap is specified as a fraction of the used graph size. If zero the graphs will be adjacent, if 1 then the gaps will be the same size as the graphs. If neither is specified, then the bars will be shown in groups (adjacent to each other) with the bars_gap between the groups.

Examples:

Default (serves as a baseline to compare with when modifying options):

using SomeGraphs
graph = series_bars_graph(; series_bars_values = [collect(0:10) .* 5, collect(0:10) .^ 2])
using PlotlyDocumenter
to_documenter(graph.figure)

Annotations:

using SomeGraphs
graph = series_bars_graph(; series_bars_values = [collect(0:10) .* 5, collect(0:10) .^ 2])
graph.data.bars_annotations = [AnnotationData(; title = "score", values = collect(0:10) .% 3)]
using PlotlyDocumenter
to_documenter(graph.figure)

Index