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:


The figure code would be:

\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;}
\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;}
\caption{Average values obtained for extrema computation experiment.}

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

    log basis x = {2},
    xtickten = {5,7,...,19},
\addplot[domain=100:1000] {x^2};

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.

  • Exactly what I needed! – user46317 Apr 16 '14 at 17:25

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.