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

Cannot call function_plotter #26

Open
oschijns opened this issue Oct 20, 2024 · 1 comment
Open

Cannot call function_plotter #26

oschijns opened this issue Oct 20, 2024 · 1 comment

Comments

@oschijns
Copy link

I wanted to draw simple math functions in my document but the function_plotter function is inaccessible.

@l3d00m
Copy link

l3d00m commented Nov 12, 2024

Also happens to me, as a workaround I have copied the function_plotter code from the library to my file and then it worked. Something like this:

#import "@preview/plotst:0.2.0": *

#let float_range(min, max, step: 1) = {
    if type(min) == "float" or type(max) == "float" or type(step) == "float" {
      let it = ()
      it.push(min)
      if step < 0 {
        while it.last() + step > max {
          assert(it.last() + step < it.last(), message: "step size too small to decrease float")
          it.push(it.last() + step)
        }
      } else {
        while it.last() + step < max {
          assert(it.last() + step > it.last(), message: "step size too small to increase float")
          it.push(it.last() + step)
        }
      }
      it
    } else {
      range(min, max, step: step)
    }
}
#let graph_plot_test() = {
  let equation = x => {calc.log(1 - (1-2*calc.exp(x/1.44)))}
  let start = 0
  let end = 2
  let precision =200 
  let points = ()
  for step in float_range(start, end, step: (end - start) / precision) {
    points.push((step, equation(step)))
  }
  points.push((end, equation(end)))
  
  let x_axis = axis(min: 0, max: 2, step: 0.25, location: "bottom", title: "time / s")
  let y_axis = axis(min: -1, max: 1, step: 0.25, location: "left", helper_lines: true, title: $M_z / M_0$)
  
  let pl = plot(data: points, axes: (x_axis, y_axis))
  graph_plot(pl, (100%, 25%), markings: [])
}

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

No branches or pull requests

2 participants