Filling the region between two curves in Cartesian math plot #418
-
I am using the code below, which plots the following graph:
There is some aspects that I want to improve:
Please, be patient with a newbie CeTZ user. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You can use the
Example: #cetz.canvas({
import cetz.plot
import cetz.palette
plot.plot(size: (4,4),
x-tick-step: 2,
x-minor-tick-step: 1,
y-tick-step: 5,
y-minor-tick-step: 1,
axis-style: "school-book", {
plot.add-fill-between(domain: (-4, 4),
x => (4-calc.pow(x, 2)),
x => (4-2*x),
style: palette.tango)
plot.add(((0,4), (2,0)),
mark: "o",
mark-style: (stroke: none, fill: black),
style: (stroke: none))
})
}) |
Beta Was this translation helpful? Give feedback.
You can use the
0.2.0
branch (or wait for the 0.2.0 release), which includes aplot.add-fill-between
function which does the filling you want. For the intersections, you have to place them yourself right now, by adding another plot with no lines (stroke: none
), but marks:mark: "o"
and your intersection points as data (list of points).axis-style: "school-book"
should do what you want.x-tick-step: <your-delta>
. If you want additional tick marks without labels, you can enable minor ticks, by settingx-minor-tick-step: ..
to some value.Example: