Skip to content

Gradients inappropriately applied to plot lines #149

@miles-1

Description

@miles-1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions