x축의 눈금 -2를 평소 위치에서 x축 위로 이동하고 싶습니다. (-2,0)에서 (-2,-4)까지 점선을 그었는데 이 눈금 위에 점선을 그리는 것을 원하지 않습니다.
\documentclass{amsart}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,
axis lines=middle,
xmin=-16,xmax=16,samples=201,
xlabel=$x$,ylabel=$y$,
ymin=-12,ymax=12,
restrict y to domain=-12:12,
enlargelimits={abs=1cm},
axis line style={latex-latex},
ticklabel style={font=\tiny,fill=white},
xtick={-2},ytick={\empty},
xlabel style={at={(ticklabel* cs:1)},anchor=north west},
ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]
\addplot [latex-latex,domain=-10:14] {x - 2} node [pos=0.9, anchor=north west, font=\footnotesize] {$y=\frac{x^{2}-4}{x+2}$};
\draw [thin,dashed] (-2,0) -- (-2,-4);
\draw [fill=white] (-2,-4) circle [radius=1.5pt] node[left,font=\tiny]{$(-2, \, -4)$};
\end{axis}
\end{tikzpicture}
\end{document}
답변1
배치하는 쉬운 방법하나의눈금 라벨은 다음을 통해 이루어집니다 \node
.
노트:
- 환경 내의 좌표에 액세스하는 경우 좌표계
axis
를 지정해야 합니다axis cs
.
암호:
\documentclass{amsart}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,
axis lines=middle,
xmin=-16,xmax=16,samples=201,
xlabel=$x$,ylabel=$y$,
ymin=-12,ymax=12,
restrict y to domain=-12:12,
enlargelimits={abs=1cm},
axis line style={latex-latex},
ticklabel style={font=\tiny,fill=white},
xtick={\empty},%xtick={-2},
ytick={\empty},
xlabel style={at={(ticklabel* cs:1)},anchor=north west},
ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]
\addplot [latex-latex,domain=-10:14] {x - 2} node [pos=0.9, anchor=north west, font=\footnotesize] {$y=\frac{x^{2}-4}{x+2}$};
\draw [thin,dashed] (axis cs: -2,-4) -- (axis cs: -2,0) node [above] {\tiny$-2$};
\draw [fill=white] (axis cs: -2,-4) circle [radius=1.5pt] node[left,font=\tiny]{$(-2, \, -4)$};
\end{axis}
\end{tikzpicture}
\end{document}
답변2
또 다른 방법은 xticklabel shift
키를 사용하는 것입니다.
\documentclass{amsart}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,
axis lines=middle,
xmin=-16,xmax=16,samples=201,
xlabel=$x$,ylabel=$y$,
ymin=-12,ymax=12,
restrict y to domain=-12:12,
enlargelimits={abs=1cm},
axis line style={latex-latex},
ticklabel style={font=\tiny,fill=white},
xtick={-2},ytick={\empty},
xlabel style={at={(ticklabel* cs:1)},anchor=north west},
ylabel style={at={(ticklabel* cs:1)},anchor=south west},
xticklabel shift=-16pt,
]
\addplot [latex-latex,domain=-10:14] {x - 2} node [pos=0.9, anchor=north west, font=\footnotesize] {$y=\frac{x^{2}-4}{x+2}$};
\draw [thin,dashed] (-2,0) -- (-2,-4);
\draw [fill=white] (-2,-4) circle [radius=1.5pt] node[left,font=\tiny]{$(-2, \, -4)$};
\end{axis}
\end{tikzpicture}
\end{document}
이렇게 바뀌니 참고하세요모두x 실제 사용 사례가 두 개 이상인 경우 라벨을 선택하세요.
답변3
이 예는 질문에 정확히 대답하지는 않지만 문제에 색상을 추가하는 예입니다.
\documentclass{amsart}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{color}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,
axis lines=middle,
xmin=-16,xmax=16,samples=201,
xlabel=${\color{blue}{x}}$,
ylabel=${\color{blue}{y}}$,
ymin=-12,ymax=12,
restrict y to domain=-12:12,
enlargelimits={abs=1cm},
axis line style={latex-latex},
ticklabel style={font=\tiny,fill=white},
xtick={\empty},%xtick={-2},
ytick={\empty},
xlabel style={at={(ticklabel* cs:1)},anchor=north west},
ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]
\addplot [purple, latex-latex,domain=-10:14] {x - 2} node [pos=0.9, anchor=north west, font=\footnotesize]
{\color{violet}{$y=\frac{x^{2}-4}{x+2}$}};
\draw [blue,thin,dashed] (axis cs: -2,-4) -- (axis cs: -2,0.2) node [above] {\tiny$-2$};
\draw [green, thin, dashed] (axis cs: -2, -4) -- (axis cs: 0.2, -4) node [right] {\tiny$-4$};
\draw [red, fill=white] (axis cs: -2,-4) circle [radius=1.5pt] node[left,font=\tiny]{$(-2, \, -4)$};
\end{axis}
\end{tikzpicture}
\end{document}