cetz-plot icon indicating copy to clipboard operation
cetz-plot copied to clipboard

Gradients inappropriately applied to plot lines

Open miles-1 opened this issue 2 months ago • 0 comments

I might be misunderstanding how to apply gradients to lines, but the following does not behave as I would expect.

#import "@preview/cetz:0.4.2": canvas, draw
#import "@preview/cetz-plot:0.1.3": plot

#canvas({
  import draw: *

  plot.plot(
    size: (3,3),
    axis-style: "scientific-auto",
    y-tick-step: 1,
    x-tick-step: 1,
    {
      plot.add(((0,0), (1,1)), style: (stroke: (paint: gradient.linear(black, red, black), thickness: 2pt)))
    }
  )
})
Image

There is a small amount of red at the bottom corner, but that is it.

Setting relative: "parent" in the gradient works better, but does not apply to the full length of the line, with the center of the gradient being at the center of the whole plot plus axes instead of the center of the line.

miles-1 avatar Oct 01 '25 16:10 miles-1