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:
My LaTeX MVP generating the image:
\begin{filecontents*}{data.csv}
iter;prod
0;-10589.143027099373
2080;-10137.34268961796
5948;-9823.312236854963
8461;-9531.740064852165
11565;-9374.010299137673
14779;-9174.160659364205
18133;-8812.173184097246
21281;-8524.717622361832
24346;-8334.931265113803
28693;-8260.530715627245
33657;-8144.811407051079
37692;-8026.3359694899145
41347;-7927.802055824076
45664;-7854.28445759018
50737;-7837.35420135146
54924;-7697.667649897329
59341;-7681.064772064068
64499;-7460.053337376205
71204;-7385.997574969703
76470;-7330.933540294809
78661;-7315.709786834038
81232;-7232.586421626356
\end{filecontents*}
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{csvsimple}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis} [
ymax=0,
xticklabel = {
\pgfmathparse{\tick/1000}
\pgfmathprintnumber{\pgfmathresult}\,K
},
% scaled x ticks=false,
yticklabel = {
\pgfmathparse{\tick/1000}
\pgfmathprintnumber{\pgfmathresult}\,K
},
scaled y ticks=false,
]
\addplot +[blue,mark=none] table [x=iter, y=prod, col sep=semicolon] {data.csv};
\end{axis}
\end{tikzpicture}
\end{document}
Now when I uncomment the line scaled x ticks=false,
I receive this error:
! Dimension too large.
<to be read again>
\relax
l.50 \end{axis}
?
! Emergency stop.
<to be read again>
\relax
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,
K
to each ticklabel, why do you not use it in the label ? e.g.xlabel={money [\si{\kilo\euro}]
using thesiunitx
package0 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 to0 20,000 40,000 60,000 80,000
is also not an option because it uses too much space.K
from the tick labels to the axis label. I tried that by removing theK
from my code andlualatex
still exists with the same error.0 20 40 60 80
is what you look for, simply useaxis
optionscaled ticks=base 10:-3
instead of your customxticklabel/yticklabel
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 aK
appended to each axis label because to me they feel less "out of place".