我正在尝试编写代码,以便将其编译为使用和TikZ
标记轴,就像使用、、和标记轴一样。(这样做的原因是,我可以使用和沿轴放置标题。)现在,我有x
y
extra x ticks=
extra y ticks=
TikZ
xlabel=$x$
ylabel=$y$
xlabel style={at={(ticklabel* cs:1)},anchor=north west}
ylabel style={at={(ticklabel* cs:1)},anchor=south west}
xlabel
ylabel
extra x ticks={}
和extra y ticks={}
因为TikZ
没有编译代码
extra x ticks={$x$}
和extra y ticks={$y$}
怎么了?
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=6in,axis equal image,clip=false,
axis lines=middle,
xmin=-42.5,xmax=42.5,
ymin=-42.5,ymax=42.5,
restrict y to domain=-42.5:42.5,
xtick={},ytick={},
ticklabel style={font=\tiny,fill=white},
enlargelimits={abs=0.25cm},
axis line style={latex-latex},
extra x ticks={},extra y ticks={},
extra x tick style={xticklabel style={at={(ticklabel* cs:1)},anchor=north west}},
extra y tick style={yticklabel style={at={(ticklabel* cs:1)},anchor=south west}}
]
\addplot[samples=501,domain=-40:64/41,blue] {(x + 16)/(x - 2)};
\addplot[samples=501,domain=32/13:40,blue] {(x + 16)/(x - 2)} node[above,pos=0.9,font=\footnotesize]{$y=\frac{x+16}{x-2}$};
\addplot[dashed, latex-latex, samples=2, domain=-42.5:42.5] {1} node[above,pos=0.1,font=\footnotesize]{$y=1$};
\addplot [dashed, latex-latex, samples=2, domain=-42.5:42.5] (2,x) node [pos=0.1, anchor=north, font=\footnotesize, sloped] {$x=2$};
\addplot coordinates{(5,7)} node[anchor=west,font=\footnotesize]{$(5,7)$};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
老实说,我会做相反的事情。使用轴标签作为轴,然后使用额外的刻度来表示任何额外的信息。
输出
代码
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=6in,axis equal image,clip=false,
axis lines=middle,
xmin=-42.5,xmax=42.5,
ymin=-42.5,ymax=42.5,
restrict y to domain=-42.5:42.5,
xtick={},ytick={},
ticklabel style={font=\tiny,fill=white},
enlargelimits={abs=0.25cm},
axis line style={latex-latex},
xlabel={$x$},
ylabel={$y$},
x label style={at={(axis description cs:1,.5)},anchor=north west},
y label style={at={(axis description cs:.5,1)},anchor=south west},
extra x ticks={5},
extra x tick label={Hello!},
every extra x tick/.style={tick label style={fill=none, rotate=-45,anchor=west}},
]
\addplot[samples=501,domain=-40:64/41,blue] {(x + 16)/(x - 2)};
\addplot[samples=501,domain=32/13:40,blue] {(x + 16)/(x - 2)} node[above,pos=0.9,font=\footnotesize]{$y=\frac{x+16}{x-2}$};
\addplot[dashed, latex-latex, samples=2, domain=-42.5:42.5] {1} node[above,pos=0.1,font=\footnotesize]{$y=1$};
\addplot [dashed, latex-latex, samples=2, domain=-42.5:42.5] (2,x) node [pos=0.1, anchor=north, font=\footnotesize, sloped] {$x=2$};
\addplot coordinates{(5,7)} node[anchor=west,font=\footnotesize]{$(5,7)$};
\end{axis}
\end{tikzpicture}
\end{document}