
이미지의 원에 표시된 것처럼 두 부분 사이에 약간의 간격이 있습니다.0그리고 국경. 그 작은 공백을 어떻게 없앨 수 있습니까?
MWE
위의 플롯을 생성하는 샘플 코드
% in preamble
\usepackage{pgfplots}
\pgfplotsset{compat=1.3}
\usepackage{filecontents}
\begin{filecontents*}{data.csv}
x,y
0.01,0.9583333333
0.02,0.8125
%...100 in total...
\end{filecontents*}
% in document
\begin{figure}[t]
\begin{tikzpicture}
\pgfplotsset{legend style={font=\tiny}}
\begin{axis}[
xlabel={Recall},
xtick={0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1},
ylabel={Precision},
ytick={0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1},
legend cell align=left,
legend pos=north east]
\addplot[c1, thin, mark=square, mark repeat=5] table[x=x, y=y, col sep=comma] {data.csv};
\addlegendentry{x-y};
\end{axis}
\end{tikzpicture}
\caption{plot}\label{fig:plot}
\end{figure}
업데이트:
Matlab을 사용하여 예상한 결과는 다음과 같습니다. 왼쪽 하단에 메모가 있습니다.0x축과 y축이 공유하는 라벨입니다.
답변1
댓글의 여러 제안이 해결책으로 이어졌습니다.
기본적으로 에서는 pgfplots
플롯 데이터를 기반으로 축 제한을 자동으로 감지할 때 플롯 뷰포트를 약간 확대합니다. 키 설정 enlargelimits=false
또는 를 enlarge x limits=false
사용하여 모든 축 또는 개별 축에 대해 이를 방지할 수 있습니다.
그러나 이 경우 플롯된 데이터의 경계가 원하는 축 제한과 일치하지 않습니다. 여기서 축 제한( xmin=0
등)을 설정하면 원하는 결과가 명시적으로 제공됩니다.
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\usepackage{filecontents}
\begin{filecontents*}{data.csv}
x,y
0.01,0.9583333333
0.02,0.8125
%...100 in total...
0.99,0.1875
\end{filecontents*}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
enlarge x limits=false,
xlabel={Recall},
xmin=0,xmax=1,
xtick={0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1},
ylabel={Precision},
ymin=0.1,ymax=1,
ytick={0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1},
]
\addplot table[x=x, y=y, col sep=comma] {data.csv};
\addlegendentry{x-y};
\end{axis}
\end{tikzpicture}
\end{document}