# pgfplot | tikzpicture | changing length + width of ticks

While there are any number of posts on how to fiddle (from the Latin) with tick labels, or tick placements, or tick color, I haven't been able to find anything (in terms of worked examples, or in the documentation), for how to change the length and width of the ticks themselves. Perhaps I simply haven't found the right search phrase(s).

At any rate, the question probably doesn't need an MWE, but to provide one for a simple 'answer by demonstration', here is a simple plot where I'd like to decrease the length (distance from top of tick mark to axis) by (say) 50%, relative to the default length. Thanks much in advance.

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}
[width=190pt,axis x line=middle, axis y line=center,
tick align=outside,
xmin=0.3,xmax=7.7,ymin=0.44,ymax=1.05,
xlabel={\emph{x-axis label}},ylabel={\emph{y-axis label}},
xtick={1,2,3,4,5,6,7},ytick={0.5,0.6,0.7,0.8,0.9,1.0},
x label style={at={(axis description cs:0.5,-0.1)},anchor=north},
y label style={at={(axis description cs:-0.1,.5)},rotate=90,anchor=south},
every tick/.style={black,semithick,height=1cm},
ylabel style={yshift=0.2cm}, xlabel style={yshift=-0.2cm}]
(1,1)
(2,0.75)
(3,0.666)
(4,0.625)
(5,0.6)
(6,0.5833)
(7,0.571)
};
\addplot [red, dashed, no markers, thick] coordinates {(0.3,0.5) (7.7,0.5)};
\end{axis}
\end{tikzpicture}
\end{document}


The tick length can be configured with option major tick length (or the alias tickwidth. Minor ticks are configured with option minor tick length (or subtickwidth). In this case, we have major ticks only. The default is 0.15cm and can be derived by \pgfkeysvalueof{/pgfplots/major tick length}. I found the option names in section "4.15.4 Tick Fine-Tuning" of the manual of pgfplots.

Example, which sets the tick length to 50 % of the default:

\documentclass{article}
\usepackage{pgfplots}
%\pgfplotsset{compat=1.12}

\begin{document}
\begin{tikzpicture}
\pgfmathsetlengthmacro\MajorTickLength{
\pgfkeysvalueof{/pgfplots/major tick length} * 0.5
}
\begin{axis}[
width=190pt,
axis x line=middle,
axis y line=center,
tick align=outside,
xmin=0.3,
xmax=7.7,
ymin=0.44,
ymax=1.05,
xlabel={\emph{x-axis label}},
ylabel={\emph{y-axis label}},
xtick={1,2,3,4,5,6,7},
ytick={0.5,0.6,0.7,0.8,0.9,1.0},
x label style={
at={(axis description cs:0.5,-0.1)},
anchor=north,
},
y label style={
at={(axis description cs:-0.1,.5)},
rotate=90,
anchor=south,
},
major tick length=\MajorTickLength,
every tick/.style={
black,
semithick,
},
ylabel style={yshift=0.2cm},
xlabel style={yshift=-0.2cm}
]
(1,1)
(2,0.75)
(3,0.666)
(4,0.625)
(5,0.6)
(6,0.5833)
(7,0.571)
};
\addplot [red, dashed, no markers, thick] coordinates {(0.3,0.5)
(7.7,0.5)};
\end{axis}
\end{tikzpicture}
\end{document}


# Bold tick numbers

This is an answer to CroCo's comment.

Bold tick numbers can be set via option tick label style. Since the tick numbers are set in math mode by default (see \axisdefaultticklabel), \boldmath gets bold tick numbers:

tick label style=\boldmath,


• Danke -- not sure how I missed that option (or perhaps I saw it, and didn't connect the dots that it applied to my 'problem'). – Johnny Canuck May 29 '15 at 14:12
• How to make only the tick numbers bold? – CroCo Nov 22 '15 at 1:13
• @CroCo See updated answer. – Heiko Oberdiek Nov 23 '15 at 18:39