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

y-axis in log mode cannot go below 1e-6 #93

Open
SolidTux opened this issue Nov 25, 2024 · 2 comments
Open

y-axis in log mode cannot go below 1e-6 #93

SolidTux opened this issue Nov 25, 2024 · 2 comments
Labels
👿 bug Something isn't working

Comments

@SolidTux
Copy link

SolidTux commented Nov 25, 2024

When plotting in log mode, there is no way for the y-axis to go below 1e-6. Note that also the y-tick-step is necessary, as otherwise the compilation crashes due to too many ticks (is this a bug?)

Document

#import "@preview/cetz-plot:0.1.0": plot
#import "@preview/cetz:0.3.1"

#set page(width: auto, height: auto, margin: 5mm)

#cetz.canvas(
  {
    plot.plot(
      size: (6, 3),
      y-mode: "log",
      y-format: "sci",
      y-tick-step: 1,
      y-min: 1e-7,
      {
        plot.add((
          (0, 1e-7),
          (1, 1e-6),
          (2, 1e-2),
        ),
          mark: "o"
        )
      }
    )
  }
)

2024-11-25 plot

@SolidTux
Copy link
Author

SolidTux commented Nov 25, 2024

I assume this stems from the fact, that there is a floating point epsilon in cetz defined as exactly that value. One can get around this problem by rescaling the data and then scaling it back in the tick formatter. For example like this

#cetz.canvas(
  {
    plot.plot(
      size: (6, 3),
      y-mode: "log",
      y-format: y => plot.formats.sci(y / 1e2),
      y-tick-step: 1,
      y-min: 1e-5,
      {
        plot.add((
          (0, 1e-7),
          (1, 1e-6),
          (2, 1e-2),
        ).map(
          ((x, y)) => (x, y * 1e2)
        ),
          mark: "o"
        )
      }
    )
  }
)

2024-11-25 plot

@johannes-wolf johannes-wolf added the 👿 bug Something isn't working label Nov 25, 2024
@jamesrswift
Copy link
Collaborator

This is possibly related to #64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👿 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants