将百分比符号放在 x 轴上

将百分比符号放在 x 轴上

如何在 x 轴上放置百分比“%”符号?

在此处输入图片描述

\documentclass{standalone}
\usepackage{subcaption}
\usepackage{caption}
\usepackage{pgfplots, pgfplotstable}
\usetikzlibrary{positioning}
\pgfplotsset{compat=1.16,width=0.98\textwidth}
%\pgfplotsset{compat=1.16,width=0.98\textwidth}

\usepackage{tikz}
\usepackage[english,spanish]{babel}         % multilenguaje

% grid style

\pgfdeclareplotmark{mystar}{
    \node[star,star point ratio=2.25,minimum size=6pt,
    inner sep=0pt,draw=black,solid,fill=red] {};
}

\decimalpoint

\begin{document}

    \begin{tikzpicture}



    \begin{axis}[
    axis line style={black},
    legend cell align={left},
    legend style={at={(0.45,0.97)}, anchor=north west, draw=black},
    tick align=outside,
    x grid style={dashed,black!60},
    xlabel={Porcentaje de entrenamiento},
    xmajorticks=true,
    xmin=10, xmax=90,
    xtick style={color=black},
    y grid style={dashed,black!60},
    ylabel={RMSE},
    ymajorticks=true,
    ymin=0.90694, ymax=1.08646,
    ytick style={black},
    xtick align=inside,
    ytick align=inside,
    grid = both
    ]
    \addplot [mark =+,line width=1pt,blue, mark size=1.5pt,dashed]
    table {%
90 0.9508
80 0.9361
70 0.9423
60 0.9423
50 0.9439
40 0.9501
30 0.9607
20 0.9699
10 1
};
\addlegendentry{Baseline}
\addplot [mark =pentagon,line width=1pt,black, mark size=1pt]
table {%
90 0.9371
80 0.9242
70 0.937
60 0.9383
50 0.9493
40 0.9649
30 0.9976
20 1.0421
10 1.0783
};
\addlegendentry{Memory}
\addplot [mark =o,line width=1pt,green!80!black, mark size=1pt]
table {%
90 0.927
80 0.9151
70 0.9309
60 0.9364
50 0.945
40 0.9609
30 0.9759
20 0.9868
10 1.0122
};
\addlegendentry{Model}
\end{axis}

\end{tikzpicture}

\end{document}

答案1

一种方法是将以下内容添加到命令的可选参数中\begin{axis}

    xticklabel={$\pgfmathprintnumber{\tick}\%$},

注意——根据上面的 MWE,轴文本是西班牙语。

在此处输入图片描述

相关内容