암호

암호

다음 코드를 사용합니다.

\begin{tikzpicture}
\begin{axis}[
xmin=0, xmax=4, ymin=0, ymax=10,
width=9cm, height=6cm,
legend style={draw=none}]

\addplot[only marks,color=red] coordinates {
(0, 10) (0.5, 8.5) (1, 2) (2, 0.5) (3.5, 1.9)};
\addlegendentry{Experimental Data Point}

\end{axis}
\end{tikzpicture}

이미지가 표시됩니다.

여기에 이미지 설명을 입력하세요

내 취향에는 범례에 나오는 기호가 범례 텍스트에 조금 가깝습니다. 어쨌든 둘 사이의 간격을 늘릴 수 있습니까?

답변1

매뉴얼 에 따르면 pgfplots,

범례는 TikZ-행렬이므로 노드와 행렬에 영향을 미치는 모든 TikZ 옵션을 사용할 수 있습니다 [...]. 행렬은 다음과 같이 생성됩니다.

\matrix[style=every axis legend] {
    draw plot specification 1 & \node{legend 1}\\
    draw plot specification 2 & \node{legend 2}\\
    ...
};

따라서 원하는 효과를 얻기 위해 column sep의 값을 늘릴 수 있습니다.legend style

암호

\documentclass[border=2pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0, xmax=4, ymin=0, ymax=10,
width=9cm, height=6cm,
legend style={draw=none,column sep=10pt}]

\addplot[only marks,color=red] coordinates {
(0, 10) (0.5, 8.5) (1, 2) (2, 0.5) (3.5, 1.9)};
\addlegendentry{Experimental Data Point}

\end{axis}
\end{tikzpicture}
\end{document}

산출

여기에 이미지 설명을 입력하세요

답변2

\hphantom{A}둘 사이의 공간을 늘리기 위해 범례 항목을 사용하는 것은 어떻습니까 ?

여기에 이미지 설명을 입력하세요

암호

\documentclass[]{article}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=0, xmax=4, ymin=0, ymax=10,
width=9cm, height=6cm, legend pos= north east,
legend style={}]
\addplot[only marks,color=red] coordinates {
(0, 10) (0.5, 8.5) (1, 2) (2, 0.5) (3.5, 1.9)};
\addlegendentry{\hphantom{A}Experimental Data Point}
\end{axis}
\end{tikzpicture}
\end{document}

관련 정보