Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to have this x axis using pgfplots:

enter image description here,

where only number 4 has + as tick label.

I could easily make all numbers have + tick label by adding xticklabel=\pgfmathprintnumber{\tick}\,+,

\documentclass[12pt,tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\begin{document}
\begin{tikzpicture}
%If you do not like this style just delete it.
%But you will need to add to \addplot[color] this "line width=2pt, rounded corners" to change line width and add rounded corners.
\tikzset{ every path/.style={line width=2pt, rounded corners}}
\begin{axis}[
title style={text width=10cm,align=center,font=\small},
width=9cm,
height=6cm,
ymin=2,
xtick={0,...,4},
xticklabel=\pgfmathprintnumber{\tick}\,+,
]
\addplot[blue] coordinates {(0,1) (1,2) (3,4) (4,2)};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

What is the way to do it?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

Use xticklabels={0, 1, 2, 3, 4+},:

\documentclass[12pt,tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\begin{document}
\begin{tikzpicture}
%If you do not like this style just delete it.
%But you will need to add to \addplot[color] this "line width=2pt, rounded corners" to change line width and add rounded corners.
\tikzset{ every path/.style={line width=2pt, rounded corners}}
\begin{axis}[
title style={text width=10cm,align=center,font=\small},
width=9cm,
height=6cm,
ymin=2,
xtick={0,...,4},
xticklabels={0, 1, 2, 3, 4+},
]
\addplot[blue] coordinates {(0,1) (1,2) (3,4) (4,2)};
\end{axis}
\end{tikzpicture}
\end{document}

plot with custom ticks

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.