我是 TikZ/pgfplotting 的新手。我不明白为什么我得到的是这些x,xxx,999
值而不是整数值。我尝试过多次x,xxx,000
更改ymax
,值但都失败了。也无济于事。我该怎么做才能完美地表示这些数据?ymin
ytick={}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\usepackage{pgfplots}
\usepackage{import}
\pgfplotsset{compat=newest,
scaled ticks=false,
yticklabel style={
/pgf/number format/.cd,
fixed,
precision=0,
fixed zerofill,
/tikz/.cd},
every tick label/.append style={font=\small},
}
\begin{figure}
\begin{subfigure}[t]{0.48\linewidth}
\begin{tikzpicture}[scale=0.9]
\begin{axis}[
legend style={font=\fontsize{7}{5}\selectfont},
xtick={0,5,10,...,50},
%ytick={2238000,2239000,...,2247000},
xmin=0,
xmax=50,
ymin=2238000,
ymax=2247000,
xlabel=Trials (n) $\rightarrow$,
ylabel=Total Cost (\$) $\rightarrow$,
grid=both,
minor grid style={gray!25},
major grid style={gray!25},
width=0.9\linewidth,]
\addplot[blue] table [x=a, y=c, col sep=comma] {./Datas/40_unit_50_trials.csv};
\addlegendentry{Total Costs at Trials}
\addplot[red] table [x=a, y=c, col sep=comma] {./Datas/avg_40_unit_50_trials.csv};
\addlegendentry{Average Total Cost}
\end{axis}
\end{tikzpicture}
\caption{}
\end{subfigure}
\end{figure}
答案1
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0, xmax=50,
xtick distance=5,
ymin=2238000, ymax=2247000,
scaled ticks=false,
yticklabel style={/pgf/number format/.cd, relative*={3}, relative style=fixed, 1000 sep={\,}},
]
\end{axis}
\end{tikzpicture}
\end{document}