diff --git a/src/plot.typ b/src/plot.typ index 7aa0611..21cf098 100644 --- a/src/plot.typ +++ b/src/plot.typ @@ -7,13 +7,19 @@ // TODO: Refactor this into a better way of providing palettes -#let default-colors = (blue, red, green, yellow, black) +#let default-colors = ( + rgb("#1982c4"), + rgb("#ff595e"), + rgb("#ffca3a"), + rgb("#8ac926"), + rgb("#6a4c93") +) #let default-plot-style(i) = { let color = default-colors.at(calc.rem(i, default-colors.len())) return ( stroke: color, - fill: color.lighten(75%) + fill: color.transparentize(80%) ) } diff --git a/src/plot/elements/xy.typ b/src/plot/elements/xy.typ index bfe1b5b..082a2e7 100644 --- a/src/plot/elements/xy.typ +++ b/src/plot/elements/xy.typ @@ -96,8 +96,10 @@ self.epigraph = self.at("epigraph", default: false) self.fill = self.at("fill", default: false) if self.hypograph or self.epigraph or self.fill { - self.fill-paths = util.compute-fill-paths(self.line-data, - (x.min, y.min), (x.max, y.max)) + self.fill-paths = (ctx.compute-fill-paths)( + self.line-data, + ctx, + ) } return self diff --git a/src/plot/styles.typ b/src/plot/styles.typ index ea9e212..3e5f4e0 100644 --- a/src/plot/styles.typ +++ b/src/plot/styles.typ @@ -42,8 +42,8 @@ anchor: auto, // Axis label anchor angle: auto, // Axis label angle ), - axis-layer: 0, - grid-layer: 0, + axis-layer: 2, + grid-layer: -1, background-layer: 0, padding: 0, tick: ( diff --git a/tests/plots/orthorect-2d/scatter/test.typ b/tests/plots/orthorect-2d/scatter/test.typ index 40f0a56..9e03e83 100644 --- a/tests/plots/orthorect-2d/scatter/test.typ +++ b/tests/plots/orthorect-2d/scatter/test.typ @@ -6,14 +6,33 @@ cetz-plot.plot( axis-style: cetz-plot.axis-style.orthorect-2d, size: (12,7), - // x-min: 1, x-max: 100, x-tick-step: 1, x-minor-tick-step: 1, - // x-mode: "log", + + x-tick-step: calc.pi / 4, + x-minor-tick-step: calc.pi / 16, x-grid: "both", - y-min: 0, y-max: 10, + x-min: 0, x-max: 2 * calc.pi, + x-format: cetz-plot.axes.format.multiple-of, + + y-min: -1, y-max: 1, y-tick-step: 0.5, y-minor-tick-step: 0.1, y-grid: "both", { - cetz-plot.add.xy((x)=>{- 0.5*x*x + 3*x + 0.025*x*x*x }, domain: (0,10), label: $y=x$, line: "raw") + cetz-plot.add.xy( + calc.sin, + domain: (0,2*calc.pi), + label: $y=x$, + line: "raw", + samples: 100, + epigraph: true, + ) + cetz-plot.add.xy( + (t)=>calc.pow(calc.sin(t),2), + domain: (0, 2* calc.pi), + line: "raw", + samples: 100, + hypograph: true, + label: $sin^2 (x)$ + ) } ) }) \ No newline at end of file diff --git a/tests/plots/polar-2d/scatter/test.typ b/tests/plots/polar-2d/scatter/test.typ index 1fc5f81..5b28841 100644 --- a/tests/plots/polar-2d/scatter/test.typ +++ b/tests/plots/polar-2d/scatter/test.typ @@ -21,14 +21,16 @@ domain: (0,2*calc.pi), label: $y=x$, line: "raw", - samples: 50 + samples: 100, + epigraph: true, ) cetz-plot.add.xy( (t)=>calc.pow(calc.sin(t),2), domain: (0, 2* calc.pi), line: "raw", - samples: 50, + samples: 100, + hypograph: true, label: $sin^2 (x)$ ) }