Skip to content
New issue

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

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

Already on GitHub? # to your account

[axis] Automatically adjusting axis #13

Open
dscso opened this issue Jul 22, 2023 · 3 comments
Open

[axis] Automatically adjusting axis #13

dscso opened this issue Jul 22, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@dscso
Copy link
Contributor

dscso commented Jul 22, 2023

I was thinking about implementing an automatically adjusting axis that also automagically selects a good scale. I am still thinking about how to implement in the most intuitive way:

#let graph_plot_test() = {
    let data = ((0, 0), (2, 2), (3, 0), (4, 4), (5, 7), (6, 6), (7, 9), (8, 5), (9, 9), (10, 1))

    let x_axis = axis(min: auto, max: auto, step: auto, location: "bottom") // this should scale the x axis automatically
    let y_axis = axis(min: 0, max: 10, step: 2, location: "left", helper_lines: false)
    let pl = plot(data: data, axes: (x_axis, y_axis))
    graph_plot(pl, (100%, 25%))
    graph_plot(pl, (100%, 25%), rounding: 30%, caption: "Graph Plot with caption and rounding", markings: [#emoji.rocket])
}
  1. So if the min, max and steps are not set, we could calculate this based on the data in the scatter_plot function for instance. I could try to implement this I just want to be on the same page API wise
  2. It would be also nice if min and max are set to give the option to cut of data that is outside of this interval. Maybe introducing another parameter min_max_cutoff: true

You have some further suggestions?

@Gewi413
Copy link
Collaborator

Gewi413 commented Jul 22, 2023

  1. Can be done in prepare_plot to allow for all plots. The algorithm from chartist doesn't seem too bad. But what to do when not all parameters are auto? If one min/max is missing, just calculate the other in a similar fashion. And the step maybe misuse step a bit and just go for each x000 number or keep the min number precisely.

  2. Can even be done by setting the plot box's clip: true. No calculations needed. Just don't render everything outside.

@dscso
Copy link
Contributor Author

dscso commented Jul 22, 2023

  1. The algorithm will determine the min/max only for those that are not provided (none), otherwise it will just assume the provided min/max/steps as given. It should not make a big difference for the algorithm.
    I just recall that once I used the algorithm from d3js this one might be more flexible. Depending what makes most of sense it uses either a $10^n$, $2^n$ or $5^n$ scale...

  2. clip: true still poses some problems for me... But by giving the option of min: auto etc. this problem should be fixed

clip-true

Are we on the same page or you have some further ideas? then I would write this and create a pull request when I am done.

@Pegacraft
Copy link
Owner

Hey hey - I think we are on the same page now. Thanks for helping developing ^^ Looking forward to your PR.

@Pegacraft Pegacraft added the enhancement New feature or request label Jul 25, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants