Verschieben eines Teilstrichs

Verschieben eines Teilstrichs

Ich möchte den Teilstrich -2 auf der X-Achse von seiner üblichen Stelle nach oben verschieben. Ich habe eine gestrichelte Linie von (-2,0) nach (-2,-4) gezeichnet und möchte nicht, dass sie über diesen Teilstrich gezogen wird.

\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}

Antwort1

Eine einfache Möglichkeit, eineinzelDie Beschriftung des Häkchens erfolgt über \node:

Bildbeschreibung hier eingeben

Anmerkungen:

  • Wenn Sie auf Koordinaten innerhalb der axisUmgebung zugreifen, sollten Sie das axis csKoordinatensystem angeben.

Code:

\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}

Antwort2

Eine andere Möglichkeit mit dem xticklabel shiftSchlüssel:

\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}

Bildbeschreibung hier eingeben

Beachten Sie, dass sich dies verschiebtallex Häkchen bei Beschriftungen, wenn Ihr tatsächlicher Anwendungsfall mehr als eine hat.

Antwort3

Dieses Beispiel beantwortet die Frage nicht genau, verdeutlicht aber, wie das Problem noch verschärft wird:

\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}

verwandte Informationen