I have the following code
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{filecontents}
\begin{filecontents}{testdata.dat}
6.3e-05 0.8767984145412976 0.6
0.000125 12.85965577546382 9.970000000000001
0.00025 16.95140970189756 13.76
0.0005 14.61328253838453 12.13
0.001 21.24630316052836 17.76
0.002 33.45255040918443 27.81
0.004 0 17.97
0.0056 0 0
0.008 0 0
0.0112 0 0
0.016 0 0
0.0224 0 0
0.0315 0 0
\end{filecontents}
\usetikzlibrary{calc}
\usetikzlibrary{pgfplots.groupplots}
\pgfplotstableread{testdata.dat}\datatable
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar=0pt,
/pgf/bar width=5pt,
bar cycle list,
width=6cm,
height=2cm,
scale only axis,
xmajorgrids,
ymin=0, ymax=100,
ymajorgrids,
tick label style={font=\scriptsize},
x tick label style={/pgf/number format/sci},
xticklabels from table={\datatable}{0}
]
\addplot table[x expr=\coordindex,y=1]{\datatable};
\addplot table[x expr=\coordindex,y=2]{\datatable};
\end{axis}
\end{tikzpicture}
\end{document}
which gives me this plot
Now instead of the fixed format for the xticklabels I want the scientific format and want an xtick on every delivered coordinate. How do I achieve this? I tried it with x tick label style={/pgf/number format/sci}
but that did not help.
Update:
To have every xtick I had to use the option xtick=data
.
Best Answer
1
xtick=data
means the x-axis from data.2 But
xticklabels from table
means the x-axis format from data.That is, if you want the legend read from
\datatable
, use first method.The example from PGFplots Official website shows the difference in two methods. The example 323(or in Manual version 1.8 page 302)
Note that
xtick
refers to values, andxticklabels
refers to format.So if I change your code,
xticklabels from table={\datatable}{0}
toxtick=data
, it's done. But it is ugly then.