我想要使用这个 x 轴pgfplots
:
,
其中仅数字 4 具有+
刻度标签。
我可以通过添加轻松使所有数字都有+
刻度标签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}
有什么办法呢?
答案1
使用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}