
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
\definecolor{color0}{rgb}{1,1,0}
\definecolor{color1}{rgb}{1,0.647058823529412,0}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis line style={black},
scaled x ticks = true,
legend cell align={left},
legend style={at={(0.03,0.97)}, anchor=north west, draw=black},
tick align=outside,
x grid style={dashed,black!60},
xlabel={$\lambda$},
xmajorticks=true,
xmin=0.0055, xmax=0.1045,
xtick style={color=black},
y grid style={dashed,black!60},
ylabel={RMSE},
ymajorticks=true,
ymin=0.912938021884183, ymax=1.01339429908853,
ytick style={black},
xtick align=inside,
ytick align=inside,
grid = none,
y tick label style={
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=4
},
]
\addplot [mark = *,line width=0.8pt,blue, mark size=1pt]
table {%
0.01 0.97820029742643
0.02 0.962938632883304
0.03 0.944377590107486
0.04 0.934490513382265
0.05 0.926770707258887
0.09 0.921652885011797
0.1 0.922493653631392
};
\addlegendentry{20 f}
\addplot [mark = *,line width=0.8pt,black, mark size=1pt]
table {%
0.01 0.992629285376604
0.02 0.970555305088483
0.03 0.950769057081716
0.04 0.937408149963347
0.05 0.92888998569171
0.09 0.919757726792486
0.1 0.922265347358195
};
\addlegendentry{30 f}
\addplot [mark = *,line width=0.8pt,red, mark size=1pt]
table {%
0.01 1.00429685084556
0.02 0.976819790163343
0.03 0.955650609854943
0.04 0.939869451503815
0.05 0.927933873176105
0.09 0.917634061468206
0.1 0.920597626159782
};
\addlegendentry{50 f}
\addplot [mark = *,line width=0.8pt,yellow, mark size=1pt]
table {%
0.01 1.00882810467015
0.02 0.972771038904076
0.03 0.955085239938932
0.04 0.941800125612627
0.05 0.930788565993547
0.09 0.917504216302563
0.1 0.920804593468368
};
\addlegendentry{100 f}
\addplot [mark = *,line width=0.8pt,orange, mark size=1pt]
table {%
0.01 1.00130716487781
0.02 0.97125309142477
0.03 0.952896925523292
0.04 0.940895422722576
0.05 0.931374232049292
0.09 0.920535667968586
0.1 0.920701204441381
};
\addlegendentry{150 f}
\end{axis}
\end{tikzpicture}
\end{document}
답변1
1. x-틱 크기 조정
scaled x ticks = base 10:2,
2. 숫자 형식 변경
xticklabel style={
/pgf/number format/fixed,
/pgf/number format/precision=2},
3. xticks 수를 줄이세요.
필요한 xtick 라벨만 나열
xtick={0.00,0.02,...,0.12},
또는, 증가 xtick distance
(댓글에 따라스테판 핀노우)
xtick distance=0.02,
암호
\documentclass[border=3mm]{standalone}
\usepackage{subcaption}
\usepackage{caption}
\usepackage{pgfplots, pgfplotstable}
\usetikzlibrary{positioning}
\usepgfplotslibrary{units}
\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
\definecolor{color0}{rgb}{1,1,0}
\definecolor{color1}{rgb}{1,0.647058823529412,0}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis line style={black},
% scaled x ticks = base 10:2,
% xticklabel style={
% /pgf/number format/fixed,
% /pgf/number format/precision=2},
xtick={0.00,0.02,...,0.12},
legend cell align={left},
legend style={at={(0.03,0.97)}, anchor=north west, draw=black},
tick align=outside,
x grid style={dashed,black!60},
xlabel={$\lambda$},
xmajorticks=true,
xmin=0.0055, xmax=0.1045,
xtick style={color=black},
y grid style={dashed,black!60},
ylabel={RMSE},
ymajorticks=true,
ymin=0.912938021884183, ymax=1.01339429908853,
ytick style={black},
xtick align=inside,
ytick align=inside,
grid = none,
y tick label style={
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=4
},
]
\addplot [mark = *,line width=0.8pt,blue, mark size=1pt]
table {%
0.01 0.97820029742643
0.02 0.962938632883304
0.03 0.944377590107486
0.04 0.934490513382265
0.05 0.926770707258887
0.09 0.921652885011797
0.1 0.922493653631392
};
\addlegendentry{20 f}
\addplot [mark = *,line width=0.8pt,black, mark size=1pt]
table {%
0.01 0.992629285376604
0.02 0.970555305088483
0.03 0.950769057081716
0.04 0.937408149963347
0.05 0.92888998569171
0.09 0.919757726792486
0.1 0.922265347358195
};
\addlegendentry{30 f}
\addplot [mark = *,line width=0.8pt,red, mark size=1pt]
table {%
0.01 1.00429685084556
0.02 0.976819790163343
0.03 0.955650609854943
0.04 0.939869451503815
0.05 0.927933873176105
0.09 0.917634061468206
0.1 0.920597626159782
};
\addlegendentry{50 f}
\addplot [mark = *,line width=0.8pt,yellow, mark size=1pt]
table {%
0.01 1.00882810467015
0.02 0.972771038904076
0.03 0.955085239938932
0.04 0.941800125612627
0.05 0.930788565993547
0.09 0.917504216302563
0.1 0.920804593468368
};
\addlegendentry{100 f}
\addplot [mark = *,line width=0.8pt,orange, mark size=1pt]
table {%
0.01 1.00130716487781
0.02 0.97125309142477
0.03 0.952896925523292
0.04 0.940895422722576
0.05 0.931374232049292
0.09 0.920535667968586
0.1 0.920701204441381
};
\addlegendentry{150 f}
\end{axis}
\end{tikzpicture}
\end{document}
답변2
편집하다:xtick
이제 나는 다른 답변이 내가 제안한 것과 동일한 레이블 솔루션을 추가했다는 것을 늦게 알았습니다 . :-(. 그래서 주제에서 벗어난 몇 가지 제안 만 ...
패키지를 사용하고 값 filecontents
의 소수 자릿수를 y
4로 줄여 다이어그램을 디자인하겠습니다(제 생각에는 여전히 만족스러운 정확도를 제공합니다).
\documentclass[margin=3mm]{standalone}
\usepackage[english,spanish]{babel} % multilenguaje
\usepackage{pgfplots}
\usetikzlibrary{babel,
positioning}
\pgfplotsset{compat=1.16,width=0.98\linewidth}
\usepackage{filecontents}
\begin{filecontents}{performance.data}
x A B C D E
0.01 0.9782 0.99262 1.0042 1.0088 1.0013
0.02 0.9629 0.97055 0.9768 0.9727 0.9712
0.04 0.9344 0.93740 0.9398 0.9418 0.9408
0.05 0.9267 0.92888 0.9279 0.9307 0.9313
0.09 0.9216 0.91975 0.9176 0.9175 0.9205
0.1 0.9224 0.92226 0.9205 0.9208 0.9207
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
grid = none,
legend style={font=\small},
legend cell align=left,
legend pos=north east,
xmin=0.005, xmax=0.105,
ylabel={RMSE},
xlabel={$\lambda$},
%
xticklabel style={font=\small,
/pgf/number format/fixed},
yticklabel style={font=\small},
%
every axis plot post/.append style={line width=0.8pt},
%
mark size=1pt,
cycle list={
{blue,mark=*},
{black,mark=*},
{red,mark=*},
{yellow,mark=*},
{orange,mark=otimes*}% <-- don't add a comma here
},
]
\addplot table [y=A] {performance.data};
\addlegendentry{20 f}
\addplot table [y=B] {performance.data};
\addlegendentry{30 f}
\addplot table [y=C] {performance.data};
\addlegendentry{50 f}
\addplot table [y=D] {performance.data};
\addlegendentry{100 f}
\addplot table [y=E] {performance.data};
\addlegendentry{150 f}
\end{axis}
\end{tikzpicture}
\end{document}