#calc.atan with cetz.plot

4 messages · Page 1 of 1 (latest)

swift thunder
#

Can anyone tell me why calc.atan is not working in this context?

#align(center)[
  #canvas({
    import draw: *
    
    plot.plot(
      size: (5, 5),
      axis-style: "school-book",
      x-tick-step: 1,
      x-min: -1.5, 
      x-max: 1.5,
      y-tick-step: 1, 
      y-min: -1.5, 
      y-max: 1.5,
      legend: "north-east",
      {
        plot.add(
          calc.tan, 
          domain: (-1.5, 1.5), 
          style: (stroke: blue),
          label: $tan(x)$
        )
        // plot.add(
        //   calc.atan, 
        //   domain: (-1, 1), 
        //   style: (stroke: red),
        //   label: $arctan(x)$
        // )
        plot.add(
          lin, 
          domain: (-1.5, 1.5), 
          style: (stroke: gray),
          label: $x = y$
        )
      })
  })
]
toxic stirrup
#

calc.atan returns angle which cant just be plotted as-is, you will have to convert it to a floating point value like its radians or degrees

#

?r t=l

#import "@preview/cetz:0.3.2"
#import "@preview/cetz-plot:0.1.1": plot


#align(center)[
  #cetz.canvas({
    import cetz.draw: *
    
    plot.plot(
      size: (5, 5),
      axis-style: "school-book",
      x-tick-step: 1,
      x-min: -1.5, 
      x-max: 1.5,
      y-tick-step: 1, 
      y-min: -1.5, 
      y-max: 1.5,
      legend: "north-east",
      {
        plot.add(
          calc.tan, 
          domain: (-1.5, 1.5), 
          style: (stroke: blue),
          label: $tan(x)$
        )
        plot.add(
          x => calc.atan(x).rad(), 
          domain: (-calc.pi, calc.pi), 
          style: (stroke: red),
          label: $arctan(x)$
        )
      })
  })
]