5

I have frequently the problem that too many data points are available for the x axis, I want to show them all in the actual plot, but I would like to show only a subset of the ticks. For instance, if I have values 2^3,..,2^32 in my x axis, I would like to display only 2^3, 2^5, 2^7 and so on (show one, skip one)

An example output is here:

image

The figure code would be:

\begin{figure}[!htb]
\centering
\begin{tabular}{rl}
\hspace{-5mm}
\begin{tikzpicture}
\begin{axis}[title = GB/s, xtick=data, xmode=log,log basis x={2},
          width=8cm, height=5.5cm,  ymajorgrids,legend columns=-1,               
legend entries={MinMax UT, MinMax SSE, MinMax AVX2},
legend to name=named, legend style = {font = {\sffamily\scriptsize}} ]
\pgfplotstableread{benchmarks/minmaxexcess/data.dat} \tableRAW
\foreach \p in {1,3,5} {\addplot table [y index = \p] from \tableRAW;}
\end{axis}
\end{tikzpicture}%
\hspace{-4mm}
&
\begin{tikzpicture}
\begin{axis}[title = Average CM/op, ymode=log, xtick=data, xmode=log,log         basis x={2},
          width=8cm, height=5.5cm,  ymajorgrids, ]
\pgfplotstableread{benchmarks/minmaxexcess/data.dat} \tableRAW
\foreach \p in {2,4,6} {\addplot table [y index = \p] from \tableRAW;}
\end{axis}
\end{tikzpicture}%
\\
\multicolumn{2}{c}{\ref{named}}\\
\end{tabular}
\vspace{-3mm}
\caption{Average values obtained for extrema computation experiment.}
\label{fig:extrema}
\end{figure}
0

1 Answer 1

7

You could give the xticks directly. The manual reveals that one can use the 1,3,...,19 writing style (as it is used in a foreach statement). A minimal example without data would be

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{loglogaxis}[
    log basis x = {2},
    xtickten = {5,7,...,19},
]
\addplot[domain=100:1000] {x^2};
\end{loglogaxis}
\end{tikzpicture}
\end{document}

The xtickten option is used to provide the ticks instead of xtick because I gave exponents instead of the full value.

Btw: Your MWE is still not very useful because we don't have your data files. A good idea should be one file that one can copy and compile without further alteration.

1
  • Exactly what I needed!
    – user46317
    Apr 16, 2014 at 17:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .