[Tex/LaTex] How to fix the space between each x ticks in a pgfplot

pgfplotstikz-pgf

I want to plot some data using pgfplot. Here is what I got for now:

\begin{tikzpicture}
\begin{axis}[
  xlabel=X,
  xmin = 0,
  xtick = {1,2,3,4,8},
  ylabel=Y,
  enlargelimits=false
]

\addplot coordinates {
  (1,   2000)
  (2,   5000)
  (3,   8000)
  (4,   11000)
  (8,   13000)
};
\addlegendentry{A}
\end{axis}
\end{tikzpicture}

The display is OK, but I do not want to have more space between 4 and 8 than between 1 and 2. I want the same space between each x tick.

Is that possible ?

Best Answer

You could change the xtick and xticklabels as follows

  xtick = {1,2,3,4,5},
  xticklabels = {1,2,3,4,8},

which gives

screenshot

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
  xlabel=X,
  xmin = 0,
  xtick = {1,2,3,4,5},
  xticklabels = {1,2,3,4,8},
  ylabel=Y,
  enlargelimits=false
]

\addplot coordinates {
  (1,   2000)
  (2,   5000)
  (3,   8000)
  (4,   11000)
  (5,   13000)
};
\addlegendentry{A}
\end{axis}
\end{tikzpicture}

\end{document}