plotly / plotly/plotly.rs

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

Open
#391 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
1.5k
Forks
128
PR merge metrics
No merged PRs in 30d

Description

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: https://github.com/plotly/plotly.py/issues/5582

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with examples/statistical_charts and the bar_chart_with_error_bars entry point, then inspect how the generated chart configuration represents BarMode::Group when a trace uses y2. Compare the output with the shown result; done means the two y-axis bar traces render side by side in grouped mode rather than overlaying.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.