Graphics, Figures & Tablespgfplots | Increase the Number of x Ticks

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
nfh
Posts: 1
Joined: Fri Jul 22, 2011 10:54 pm

pgfplots | Increase the Number of x Ticks

Post by nfh »

Hi,

I'm creating a few charts using the pgfplots library. One of those charts has "distance" on the x axis, but the generated image has ticks with a 2km interval (0 2 4 6 ... 14).

How can I tell pgfplots to generate x ticks with, for example, a 0.5 interval between ticks (0.5 1 1.5 2 2.5 ... 14)?

Best regards.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

indridi
Posts: 4
Joined: Thu Sep 17, 2009 7:53 pm

pgfplots | Increase the Number of x Ticks

Post by indridi »

This, from the pgfplots manual, should do the trick:

Code: Select all

\begin{tikzpicture}
\begin{axis}[
xtick={-1.5,-1,...,1.5},
xticklabels={%
$-1\frac 12$,
$-1$,
$-\frac 12$,
$0$,
$\frac 12$,
$1$},
% note: \frac can be done automatically:
% xticklabel style={/pgf/number format/frac},
]
\addplot[smooth,blue,mark=*]
coordinates {
(-1, 1)
(-0.75, 0.5625)
(-0.5, 0.25)
(-0.25, 0.0625)
(0, 0)
(0.25, 0.0625)
(0.5, 0.25)
(0.75, 0.5625)
(1, 1)
};
\end{axis}
\end{tikzpicture}
Post Reply