Correct way of using an existing palette in a plot #718
-
#import "@preview/cetz:0.2.2"
cetz.canvas({
import cetz.plot: plot, add
import cetz.draw: translate, set-style
import cetz.palette: tango, blue
let size = (7, 6)
let offset = (size.at(0) + 1, 0)
let start = 0.001
let end = 1
let domain = (start, end)
plot(
size: size, x-tick-step: 0.5, y-tick-step: 0.2,
x-min: start - 0.1,
x-max: end + 0.1,
y-min: - 0.1,
x-label: [Wavenumber $k$ (rad/s)],
y-label: [Energy $P(k) (m^2 s$)],
plot-style: tango, // <--------- is this correct?
legend: "legend.inner-north-east",
{
add(domain: domain, line: "spline", label: [10km], t => jonswapEnergy(t, 10000, 10))
add(domain: domain, line: "spline", label: [20km], t => jonswapEnergy(t, 20000, 10))
add(domain: domain, line: "spline", label: [50km], t => jonswapEnergy(t, 50000, 10))
add(domain: domain, line: "spline", label: [100km], t => jonswapEnergy(t, 100000, 10))
}
)}) I was wondering how to use a palette with a plot, I would like to change line colors. In the docs it says that the plot-style parameter of plot accepts a function and saw a discussion for bar charts that uses the parameter bar-style in a similar way |
Beta Was this translation helpful? Give feedback.
Answered by
DamianoPellegrini
Oct 11, 2024
Replies: 1 comment
-
This seems to be a solution, I was missing the plot-style: i => (fill: none, ..cetz.plot.default-plot-style(i), ..tango(i, stroke: true)), Not really clear from the documentation/manual, I had to read the source code and |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
DamianoPellegrini
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems to be a solution, I was missing the
stroke: true
in the palette function:Not really clear from the documentation/manual, I had to read the source code and
#repr
results in order to find this.