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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 7 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
1  
I'm interested in this question too. What if xtick={0,3,...,102} and I want to change only the label corresponding to 57? Apart from this specific example, what I want to do is to substitute the central xticklabel with the xlabel, in order to gain vertical space in the page. – Enrico Maria De Angelis Oct 17 '15 at 7:38

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.