# specify the step of pgfplots axis

Now the numbers on the x-axis are

0, 0.5, 1, 1.5, 2

I want to show integer only:

0, 1, 2

How can I do that? My code:

\begin{tikzpicture}
\begin{axis}[
ylabel=speedup & deviation]
\end{axis}
\end{tikzpicture}


The content of datafile.dat:

thread  speedup dev
1   1   0
2   3   1
3   5   0
4   7   1

-
For example, you can include a compilable minimal code and we can have a look together :) –  percusse Mar 9 '12 at 2:37

If you want to have the x ticks to appear exactly as entered you can use the option xtick=data.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
1   1   0
2   3   1
3   5   0
4   7   1
}\datafile

\begin{tikzpicture}
\begin{axis}[
ylabel=speedup \& deviation,
xtick=data]
\end{axis}
\end{tikzpicture}
\end{document}


or you can enter manually by xtick={1,2,3,4} option

-
This wouldn't be ideal with large sets of data. –  Magpie Mar 12 '13 at 20:01
@Magpie then you use explicit ticks or leave it to pgfplots anyway. –  percusse Mar 12 '13 at 22:41

Section 4.14 of the pgfplots manual describes the xtick option, which gives a list of locations for the ticks. In this case xtick={1,...,4} should do the trick.

Here's an example:

\documentclass{article}
\usepackage{pgfplots}

% example data file
\usepackage{filecontents}
\begin{filecontents}{datafile.dat}
1 1 0
2 3 1
3 5 0
4 7 1
\end{filecontents}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
ylabel=speedup \& deviation,
xtick={1,...,4}]

\end{axis}
\end{tikzpicture}
\end{document}


(EDIT: Different section numbers for difference versions of the manual)

-
What about axis that go from -4 to 4? –  Magpie Mar 12 '13 at 20:01

Use xtick={0, 1, 2} to specify where you want the xticks:

## Notes:

• This also necessitated specifying xmin=0 to get the marker for x=0.
• You also need to \& for the ylabel.

## Code:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{filecontents}

\begin{filecontents*}{datafile.dat}
1   1   0
2   3   1
3   5   0
4   7   1
\end{filecontents*}

\begin{document}
\begin{tikzpicture}
\begin{axis}[