Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot: Contour Plots #243

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 0.1.3

## Libs
### Plot
- Added `plot.add-contour(..)` for plotting contour plots
- Added `plot.add-hline(..)` and `plot.add-vline(..)` for plotting h/v lines
- Added `fill-type` option to `plot.add(..)` for specifying a fill type (axis or shape)
- Changed default samples from 100 to 50!
- Fixed plot filling in some cases

# 0.1.2
CeTZ requires Typst 0.8.0.
## Draw
Expand Down
Binary file modified manual.pdf
Binary file not shown.
24 changes: 22 additions & 2 deletions manual.typ
Original file line number Diff line number Diff line change
Expand Up @@ -854,10 +854,19 @@ The node itselfes can be of type `content` or `dictionary` with a key `content`.

== Plot
#let plot-module = tidy.parse-module(read("src/lib/plot.typ"), name: "Plot")
#let plot-module-line = tidy.parse-module(read("src/lib/plot/line.typ"),
name: "Plot - Line")
#let plot-module-contour = tidy.parse-module(read("src/lib/plot/contour.typ"),
name: "Plot - Contour")
#let plot-module-sample = tidy.parse-module(read("src/lib/plot/sample.typ"),
name: "Plot - Sample")

The library `plot` of CeTZ allows plotting 2D data as linechart.

#tidy.show-module(plot-module, show-module-name: false)
#tidy.show-module(plot-module-line, show-module-name: false)
#tidy.show-module(plot-module-contour, show-module-name: false)
#tidy.show-module(plot-module-sample, show-module-name: false)

=== Examples

Expand All @@ -884,8 +893,8 @@ import cetz.plot
import cetz.palette

// Axes can be styled!
// Set the tick length to -.05:
set-style(axes: (tick: (length: -.05)))
// Set the tick length to .1:
set-style(axes: (tick: (length: .1)))

// Plot something
plot.plot(size: (3,3), x-tick-step: 1, axis-style: "left", {
Expand All @@ -897,6 +906,17 @@ plot.plot(size: (3,3), x-tick-step: 1, axis-style: "left", {
})
```

```example
import cetz.plot
plot.plot(size: (3,2), x-tick-step: 1, y-tick-step: 1, {
let z(x, y) = {
(1 - x/2 + calc.pow(x,5) + calc.pow(y,3)) * calc.exp(-(x*x) - (y*y))
}
plot.add-contour(x-domain: (-2, 3), y-domain: (-3, 3),
z, z: (.1, .4, .7), fill: true)
})
```

=== Styling <plot.style>

The following style keys can be used (in addition to the standard keys)
Expand Down
Loading