1

Here is what I've got.

\begin{tikzpicture}[scale=1.2]
    \begin{axis}[
    xmax=20,xmin=4,
    ymin=0,ymax=0.6,
    xlabel=\emph{Number},ylabel=\emph{F1 Score},
    xtick={20,16,...,4},
    ytick={0,0.1,0.20,...,0.6},
    x dir=reverse,
    ]
     \addplot+ [mark=pentagon*,mark size=2.5pt,every mark/.append style={}] coordinates{(20, 0.37) (16, 0.33) (12, 0.29) (8, 0.23) (4, 0.21)};
     \addplot coordinates{(20, 0.46) (16, 0.45) (12, 0.45) (8, 0.43) (4, 0.42)};   
    \end{axis}
    \end{tikzpicture}%

enter image description here

but I want this

enter image description here

1

A very simple way is to add the labels explicitly.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[scale=1.2]
    \begin{axis}[
    xmax=20,xmin=4,
    ymin=0,ymax=0.6,
    xlabel=\emph{Number},ylabel=\emph{F1 Score},
    xtick={20,16,...,4},
    xticklabels={$4\cdot5$,$4\cdot4$,$4\cdot3$,$4\cdot2$,$4\cdot1$},
    xticklabel style={yshift=-0.3ex},
    ytick={0,0.1,0.20,...,0.6},
    x dir=reverse,
    ]
     \addplot+ [mark=pentagon*,mark size=2.5pt,every mark/.append style={}] coordinates{(20, 0.37) (16, 0.33) (12, 0.29) (8, 0.23) (4, 0.21)};
     \addplot coordinates{(20, 0.46) (16, 0.45) (12, 0.45) (8, 0.43) (4, 0.42)};   
    \end{axis}
\end{tikzpicture}%
\end{document}

enter image description here

You can also redefine xticklabel to become xticklabel={$\pgfmathtruncatemacro{\myx}{\tick/4}\myx\cdot4$}.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[scale=1.2]
    \begin{axis}[
    xmax=20,xmin=4,
    ymin=0,ymax=0.6,
    xlabel=\emph{Number},ylabel=\emph{F1 Score},
    xtick={20,16,...,4},
    xticklabel={$\pgfmathtruncatemacro{\myx}{\tick/4}\myx\cdot4$},
    xticklabel style={yshift=-0.3ex},
    ytick={0,0.1,0.20,...,0.6},
    x dir=reverse,
    ]
     \addplot+ [mark=pentagon*,mark size=2.5pt,every mark/.append style={}] coordinates{(20, 0.37) (16, 0.33) (12, 0.29) (8, 0.23) (4, 0.21)};
     \addplot coordinates{(20, 0.46) (16, 0.45) (12, 0.45) (8, 0.43) (4, 0.42)};   
    \end{axis}
\end{tikzpicture}%
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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