#calc.tan & cetz.plot

3 messages · Page 1 of 1 (latest)

near relic
#

When I try to plot the calc.tan function:

#align(center)[
    #canvas({
      import draw: *
      
      plot.plot(
        size: (8, 8),
        axis-style: "school-book",
        x-tick-step: 1,
        x-min: -5., 
        x-max: 5.,
        y-tick-step: 1, 
        y-min: -5, 
        y-max: 5,
        legend: "inner-north-east",
        {
          plot.add(
            // tangent,
            calc.tan,
            domain: (-5, 5), 
            style: (stroke: blue),
            label: $tan(x)$
          )
        })
    })
  ]

It might be occurring because the plotting software is connecting points across the singularities?

Does anyone know how I can prevent this?

unreal burrow
#

You should plot multiple times in each domain without singularities, in a for loop for example

unreal burrow
#

?r ```
#import "@preview/cetz:0.3.1": canvas, draw
#import "@preview/cetz-plot:0.1.0": plot

#align(center)[
#canvas({
import draw: *

  plot.plot(
    size: (8, 8),
    axis-style: "school-book",
    x-tick-step: 1,
    x-min: -5., 
    x-max: 5.,
    y-tick-step: 1, 
    y-min: -5, 
    y-max: 5,
    {
      for k in range(-4,4) {
      plot.add(
        // tangent,
        calc.tan,
        domain: (k*calc.pi/2+0.05, (k+1)*calc.pi/2-0.05), 
        style: (stroke: blue),
       )}
    })
})

]