Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve #184 #218

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Resolve #184 #218

wants to merge 20 commits into from

Conversation

yasuomaidana
Copy link

Here, you can see the current changes related to plotting multiple axes. The test had passed, but I had to update the examples and check the functionality.

@andrei-ng
Copy link
Collaborator

I will review it this week. Sorry for the delay.

@yasuomaidana
Copy link
Author

It still needs to be finished. I made the PR to show my approach. I was thinking of creating some builders to avoid cumbersome code like writing the whole Vec[Some(Box....)]. We could generate a builder from one item and another to make the axis from a vector, but I don't know what you think.

@yasuomaidana
Copy link
Author

I found in examples/subplots/src/main.rs that we can generate more than 9 axis plotting by using this example:

fn many_subplots_with_titles() {
    let trace1 = Scatter::new(vec![1, 2], vec![4, 5]);

    let number_of_plots = 10;

    let mut plot = Plot::new();
    let mut layout = Layout::new()
        .grid(
            LayoutGrid::new()
                .rows(number_of_plots / 2)
                .columns(2)
                .pattern(GridPattern::Independent),
        )
        .height(number_of_plots * 200);

    for i in 1..number_of_plots + 1 {
        plot.add_trace(
            trace1
                .clone()
                .y_axis(format!("y{}", i))
                .x_axis(format!("x{}", i)),
        );
        layout.add_annotation(
            Annotation::new()
                .y_ref(format!("y{} domain", i))
                .y_anchor(Anchor::Bottom)
                .y(1)
                .text(format!("Title {}", i))
                .x_ref(format!("x{} domain", i))
                .x_anchor(Anchor::Center)
                .x(0.5)
                .show_arrow(false),
        )
    }

    plot.set_layout(layout);
    plot.set_configuration(Configuration::new().responsive(true));
    plot.show();
}

However, I still think the current changes can be useful since these new changes are handling another path. But I wanted to mention it

@andrei-ng
Copy link
Collaborator

@yasuomaidana . I didn't manage to properly review your PR and I won't be in the next 2 weeks either. Will be back on it at end of August.

In general, it looks good. Indeed, I would prefer if we can abstract calls like these Vec[Some(Box....) behind a cleaner API. Or if we could avoid using Box altogether we will have shorter calling sequences.

@yasuomaidana
Copy link
Author

I agree with you; I considered adding add_[AXIS]_axis to the append axis instead of using a building. I already did the builder, but after reading your feedback, I noticed that that solution is not contained in the API so that it will be more verbose.

@yasuomaidana
Copy link
Author

Sorry, men, I was busy, but I back on this issue, I'll work on it this week

@andrei-ng
Copy link
Collaborator

Sorry, men, I was busy, but I back on this issue, I'll work on it this week

Sorry @yasuomaidana , I was also quite busy. I will have a look at your proposal in the next 2-3 weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants