Skip to content

Commit

Permalink
axes: Support minor ticks on reversed axis
Browse files Browse the repository at this point in the history
fixes #10
  • Loading branch information
johannes-wolf committed Jun 23, 2024
1 parent 72960ea commit 1e19862
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/axes.typ
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@
if "minor-step" in ticks and ticks.minor-step != none {
assert(ticks.minor-step >= 0,
message: "Axis minor tick step must be positive")
if axis.min > axis.max { ticks.minor-step *= -1 }

let s = 1 / ticks.minor-step

Expand Down
Binary file modified tests/axes/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 12 additions & 2 deletions tests/axes/test.typ
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#set page(width: auto, height: auto)
#import "/src/lib.typ": *
#import "/src/cetz.typ": *
#import "/tests/helper.typ": *
#import cetz: draw
#import cetz-plot: axes

// Schoolbook Axis Styling
#test-case({
Expand Down Expand Up @@ -57,3 +57,13 @@
)),
left: axes.axis(min: -1, max: 1, ticks: (step: none, minor-step: none)))
})

// #10 - Minor ticks on reversed axis
#test-case({
import draw: *

axes.scientific(size: (6, 1),
bottom: axes.axis(min: 5, max: -5,
ticks: (step: 5, minor-step: 1)),
left: axes.axis(min: -1, max: 1, ticks: (step: none, minor-step: none)))
})

0 comments on commit 1e19862

Please sign in to comment.