y = 6x - 9
为什么没有绘制线条?我有正确的xmin
、xmax
、ymin
和ymax
值。
\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,intersections,}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usepackage{mathtools,array}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=2.25in, height=2.75in, axis on top,
axis lines=middle,
xmin=-4,xmax=4, domain=-4:4,
ymin=-4,ymax=16,
restrict y to domain=-4:16,
xtick={\empty}, ytick={\empty},
xlabel=$x$,ylabel=$y$,
axis line style={latex-latex},
axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]
\addplot[samples=501, domain=-4:4] {x^2};
%\addplot[samples=2, latex-latex, domain={5/6+0.01}:{4-0.01}] {6*x - 9};
\addplot[samples=2, latex-latex, domain={5/6}:4] {6*x - 9};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
增加点数,一切就好。
\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,intersections,}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usepackage{mathtools,array}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=2.25in, height=2.75in, axis on top,
axis lines=middle,
xmin=-4,xmax=4, domain=-4:4,
ymin=-4,ymax=16,
restrict y to domain=-4:16,
xtick={\empty}, ytick={\empty},
xlabel=$x$,ylabel=$y$,
axis line style={latex-latex},
axis line style={shorten >=-12.5pt, shorten <=-12.5pt},
xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]
\addplot[samples=501, domain=-4:4] {x^2};
%\addplot[samples=2, latex-latex, domain={5/6+0.01}:{4-0.01}] {6*x - 9};
\addplot[samples=100, latex-latex, domain={5/6}:4] {6*x - 9};
\end{axis}
\end{tikzpicture}
\end{document}