cetz-package / cetz

CeTZ: ein Typst Zeichenpaket - A library for drawing stuff with Typst.
https://cetz-package.github.io
GNU Lesser General Public License v3.0
819 stars 35 forks source link

Wrong alignment of the bottom y-tick label when it is -2 #476

Closed sevesalm closed 7 months ago

sevesalm commented 7 months ago

The following plot causes the -2 tick label to be badly aligned. Interestingly this does not happen if the lowest visible y tick label is another negative integer, like -3 or -4 etc. Then the alignment is good. Only -2 seems to be problematic.

Using Typst 0.10.0.

#import "@preview/cetz:0.2.0"
#cetz.canvas({
  import cetz.plot
  import cetz.draw
  plot.plot(
    axis-style: "left", 
    size: (10, 6), 
    y-min: -2, 
    y-max: 2, 
    {
      plot.add(
        domain: (-2, 5),
        x => x,
      )
  })
})

Screenshot

Screenshot 2024-01-19 at 22 32 19
johannes-wolf commented 7 months ago

With the linked PR, you can now set-style(axes: (shared-zero: false)) to hide the shared 0 for school-book style plots. All other axis-styles do not use a shared tick label anymore (so in your example, the -2 should go away).