Skip to content

bar_mode(BarMode::Group) not working with second y axis #391

@inferrna

Description

@inferrna

Added second y axis to bar_chart_with_error_bars from examples/statistical_charts

fn bar_chart_with_error_bars(show: bool, file_name: &str) {
    let trace_c = Bar::new(vec!["Trial 1", "Trial 2", "Trial 3"], vec![3, 6, 4])
        .error_y(ErrorData::new(ErrorType::Data).array(vec![1., 0.5, 1.5]));
    let trace_e = Bar::new(vec!["Trial 1", "Trial 2", "Trial 3"], vec![400, 700, 300])
        .y_axis("y2")
        .error_y(ErrorData::new(ErrorType::Data).array(vec![50.0, 100., 200.]));

    let mut plot = Plot::new();
    plot.add_trace(trace_c);
    plot.add_trace(trace_e);

    let layout = Layout::new()
        .bar_mode(BarMode::Group)
        .y_axis(Axis::new().title("Trace C"))
        .y_axis2(
            Axis::new()
                .title(Title::from("Trace E"))
                .side(AxisSide::Right),
        );
    plot.set_layout(layout);

    let path = write_example_to_html(&plot, file_name);
    if show {
        plot.show_html(path);
    }
}

Resulting chart. Overlay instead of group.

Image

python version is also broken, but in different way - stack instead of group: plotly/plotly.py#5582

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions