Skip to content

Commit

Permalink
Merge pull request #243 from johannes-wolf/cetz-215-contour-plots
Browse files Browse the repository at this point in the history
plot: Contour Plots
  • Loading branch information
johannes-wolf authored Oct 16, 2023
2 parents 282e400 + a661c05 commit 62ef427
Show file tree
Hide file tree
Showing 27 changed files with 1,531 additions and 547 deletions.
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

0 comments on commit 62ef427

Please sign in to comment.