diff --git a/src/plot.typ b/src/plot.typ index 3b3c699..f440d3c 100644 --- a/src/plot.typ +++ b/src/plot.typ @@ -38,7 +38,7 @@ target: target, min: none, max: none, - ticks: (step: auto, minor-step: none, format: none, list: ()) + ticks: (step: auto, minor-step: none, format: "float", list: ()) ) ctx.axes.insert(name, axis) return ctx @@ -299,13 +299,6 @@ } } - // Remove unused axes - for (k, v) in ctx.axes { - if not v.at("used", default: false) { - let _ = ctx.axes.remove(k) - } - } - // Set axis options ctx.axes = plot-util.setup-axes(cetz-ctx, ctx.axes, options.named(), size) diff --git a/src/plot/util.typ b/src/plot/util.typ index 9330afd..70b5057 100644 --- a/src/plot/util.typ +++ b/src/plot/util.typ @@ -290,16 +290,22 @@ } for (name, axis) in axis-dict { + let used = axis.at("used", default: false) + if not "ticks" in axis { axis.ticks = () } - axis.label = get-axis-option(name, "label", $#name$) + axis.label = get-axis-option(name, "label", if used { $#name$ } else { axis.at("label", default: none) }) // Configure axis bounds axis.min = get-axis-option(name, "min", axis.min) axis.max = get-axis-option(name, "max", axis.max) - assert(axis.min not in (none, auto) and - axis.max not in (none, auto), - message: "Axis min and max must be set.") + if axis.min == none { + axis.min = 0 + axis.ticks.step = none + axis.ticks.minor-step = none + axis.ticks.format = none + } + if axis.max == none { axis.max = axis.min } if axis.min == axis.max { axis.min -= 1; axis.max += 1 } diff --git a/tests/axes/log-mode/ref/1.png b/tests/axes/log-mode/ref/1.png index 409c2c3..53fa4ea 100644 Binary files a/tests/axes/log-mode/ref/1.png and b/tests/axes/log-mode/ref/1.png differ diff --git a/tests/chart/boxwhisker/ref/1.png b/tests/chart/boxwhisker/ref/1.png index 07b311a..c71898b 100644 Binary files a/tests/chart/boxwhisker/ref/1.png and b/tests/chart/boxwhisker/ref/1.png differ diff --git a/tests/chart/ref/1.png b/tests/chart/ref/1.png index a9aab7b..236c26c 100644 Binary files a/tests/chart/ref/1.png and b/tests/chart/ref/1.png differ diff --git a/tests/plot/annotation/ref/1.png b/tests/plot/annotation/ref/1.png index af0ea9d..bc611b5 100644 Binary files a/tests/plot/annotation/ref/1.png and b/tests/plot/annotation/ref/1.png differ diff --git a/tests/plot/bar/ref/1.png b/tests/plot/bar/ref/1.png index 307100d..532feb7 100644 Binary files a/tests/plot/bar/ref/1.png and b/tests/plot/bar/ref/1.png differ diff --git a/tests/plot/boxwhisker/ref/1.png b/tests/plot/boxwhisker/ref/1.png index 2f1e16e..acc6e59 100644 Binary files a/tests/plot/boxwhisker/ref/1.png and b/tests/plot/boxwhisker/ref/1.png differ diff --git a/tests/plot/broken-axes/ref/1.png b/tests/plot/broken-axes/ref/1.png index fcd2e11..27057d4 100644 Binary files a/tests/plot/broken-axes/ref/1.png and b/tests/plot/broken-axes/ref/1.png differ diff --git a/tests/plot/contour/ref/1.png b/tests/plot/contour/ref/1.png index adad8ab..f7d0c39 100644 Binary files a/tests/plot/contour/ref/1.png and b/tests/plot/contour/ref/1.png differ diff --git a/tests/plot/equal-axis/ref/1.png b/tests/plot/equal-axis/ref/1.png index 7f4196f..283fd6d 100644 Binary files a/tests/plot/equal-axis/ref/1.png and b/tests/plot/equal-axis/ref/1.png differ diff --git a/tests/plot/format/ref/1.png b/tests/plot/format/ref/1.png index 2b5a0ec..a7a2925 100644 Binary files a/tests/plot/format/ref/1.png and b/tests/plot/format/ref/1.png differ diff --git a/tests/plot/grid/ref/1.png b/tests/plot/grid/ref/1.png index 550e9d5..49e291b 100644 Binary files a/tests/plot/grid/ref/1.png and b/tests/plot/grid/ref/1.png differ diff --git a/tests/plot/line/line-type/ref/1.png b/tests/plot/line/line-type/ref/1.png index 7814191..127004b 100644 Binary files a/tests/plot/line/line-type/ref/1.png and b/tests/plot/line/line-type/ref/1.png differ diff --git a/tests/plot/line/linearization/ref/1.png b/tests/plot/line/linearization/ref/1.png index ea8c022..b52049f 100644 Binary files a/tests/plot/line/linearization/ref/1.png and b/tests/plot/line/linearization/ref/1.png differ diff --git a/tests/plot/line/mark/ref/1.png b/tests/plot/line/mark/ref/1.png index f4e7ca6..8c476bc 100644 Binary files a/tests/plot/line/mark/ref/1.png and b/tests/plot/line/mark/ref/1.png differ diff --git a/tests/plot/line/spline/ref/1.png b/tests/plot/line/spline/ref/1.png index ba6e25b..e3d75f3 100644 Binary files a/tests/plot/line/spline/ref/1.png and b/tests/plot/line/spline/ref/1.png differ diff --git a/tests/plot/marks/ref/1.png b/tests/plot/marks/ref/1.png index ad6e334..3fd1fc0 100644 Binary files a/tests/plot/marks/ref/1.png and b/tests/plot/marks/ref/1.png differ diff --git a/tests/plot/mirror-axes/ref/1.png b/tests/plot/mirror-axes/ref/1.png index 4e7e062..94b2cc2 100644 Binary files a/tests/plot/mirror-axes/ref/1.png and b/tests/plot/mirror-axes/ref/1.png differ diff --git a/tests/plot/parametric/ref/1.png b/tests/plot/parametric/ref/1.png index 18557d3..02bb203 100644 Binary files a/tests/plot/parametric/ref/1.png and b/tests/plot/parametric/ref/1.png differ diff --git a/tests/plot/ref/1.png b/tests/plot/ref/1.png index 2cfb1b8..9f3c5e8 100644 Binary files a/tests/plot/ref/1.png and b/tests/plot/ref/1.png differ diff --git a/tests/plot/reverse-axis/ref/1.png b/tests/plot/reverse-axis/ref/1.png index d29c1b6..f959809 100644 Binary files a/tests/plot/reverse-axis/ref/1.png and b/tests/plot/reverse-axis/ref/1.png differ diff --git a/tests/plot/test.typ b/tests/plot/test.typ index 9ea7b68..4cf0944 100644 --- a/tests/plot/test.typ +++ b/tests/plot/test.typ @@ -136,6 +136,10 @@ yb-min: -1.5, yb-max: .5, yt-min: -.5, yt-max: 1.5, { + plot.add-cartesian-axis("xl", (0, 0), (4, 0)) + plot.add-cartesian-axis("xr", (0, 4), (4, 4)) + plot.add-cartesian-axis("yt", (0, 0), (0, 4)) + plot.add-cartesian-axis("yb", (4, 0), (4, 4)) plot.add(circle-data) plot.add(circle-data, axes: ("xl", "y"), style: (stroke: green)) plot.add(circle-data, axes: ("xr", "y"), style: (stroke: red)) @@ -155,6 +159,10 @@ yb-min: -1.75, yb-max: .25, yt-min: -.25, yt-max: 1.75, { + plot.add-cartesian-axis("xl", (0, 0), (4, 0)) + plot.add-cartesian-axis("xr", (0, 4), (4, 4)) + plot.add-cartesian-axis("yt", (0, 0), (0, 4)) + plot.add-cartesian-axis("yb", (4, 0), (4, 4)) plot.add(circle-data) plot.add(circle-data, axes: ("xl", "y"), style: (stroke: green)) plot.add(circle-data, axes: ("xr", "y"), style: (stroke: red)) diff --git a/tests/plot/vertical/ref/1.png b/tests/plot/vertical/ref/1.png index f034306..93e0cbd 100644 Binary files a/tests/plot/vertical/ref/1.png and b/tests/plot/vertical/ref/1.png differ diff --git a/tests/plot/violin/ref/1.png b/tests/plot/violin/ref/1.png index 63e1210..acfc488 100644 Binary files a/tests/plot/violin/ref/1.png and b/tests/plot/violin/ref/1.png differ