I want to change my x axis tick labels to read 0K 20K 40K 60K 80K similar to my y axis tick labels in this chart:

enter image description here

My LaTeX MVP generating the image:



\begin{axis} [
        xticklabel = {
%        scaled x ticks=false,
        yticklabel = {
        scaled y ticks=false,
    \addplot +[blue,mark=none] table [x=iter, y=prod, col sep=semicolon] {data.csv};

Now when I uncomment the line scaled x ticks=false, I receive this error:

! Dimension too large.
<to be read again> 
l.50     \end{axis}

! Emergency stop.
<to be read again> 
l.50     \end{axis}

!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on build/mvp.log.

This error message seems to be associated with divisions by zero. Due to my set denominator of 1000 I don't see how that could the cause. Therefore I have no idea why this method works for the y axis but not for the x axis. Could someone please point out what I'm doing wrong?

Update: axes with scaled ticks=base 10:-3,

Based on BambOo's suggestion: enter image description here

  • 1
    You error is more likely related to the fact that you handle relatively large numbers for the default TeX math engine. IMHO it is unnecessary to ad a K to each ticklabel, why do you not use it in the label ? e.g. xlabel={money [\si{\kilo\euro}] using the siunitx package – BambOo May 5 '20 at 12:04
  • By default the x tick labels are 0 2 4 6 8 and at the end there is a * 10^4 which is added in a new line. I want to avoid this type of visualization. Changing it to 0 20,000 40,000 60,000 80,000 is also not an option because it uses too much space. – oschlueter May 5 '20 at 12:55
  • So I'd still have to divide the tick labels by 1000 even if I move the K from the tick labels to the axis label. I tried that by removing the K from my code and lualatex still exists with the same error. – oschlueter May 5 '20 at 13:01
  • 1
    If tikc labels 0 20 40 60 80 is what you look for, simply use axis option scaled ticks=base 10:-3 instead of your custom xticklabel/yticklabel – BambOo May 5 '20 at 13:24
  • Thank you for the suggestion. I added scaled ticks=base 10:-3, to my axis and rendered the chart. I added a screenshot to the question. Now it shows * 10^3 instead of * 10^4. Is there another way I can hide this? I'd rather have a K appended to each axis label because to me they feel less "out of place". – oschlueter May 5 '20 at 15:36

The documentation of \pgfmathparse held the answer:

The math engine in pgf typically uses TEX’s internal arithmetics. That means: it is well suited for numbers in the range [−16384, 16384] and has a precision of 5 digits

The number range is typically too small for plotting applications. pgfplots improves the number range by means of \pgfkeys{/pgf/fpu}\pgfmathparse{1+41} to activate the “floating point unit” (fpu) and to apply all following operations in floating point.

Adding \pgfkeys{/pgf/fpu} into my blocks for xticklabel and yticklabel allows for the calculations required to render my axis as I want it to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.