다음 코드를 사용하면 포물선 y=x^2를 그릴 수 있지만 포물선 x=y^2를 그릴 수 없어 오류가 표시됩니다. 도와주세요.
\documentclass{article}
\usepackage{tikz,pgfplots}
%\usepackage[x11names]{xcolor}
\usepackage{tikz}
\usetikzlibrary{intersections}
\pgfdeclarelayer{bg} % declare background
\pgfsetlayers{bg,main} % order of layers (main = standard layer)
\pgfplotsset{compat=1.13}
\usepackage{amsmath}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[domain=0:2, scale = 0.75]
\draw(-4,0)--(4,0);
\draw (0,-4)--(0,4);
\draw[black, line width = 0.50mm] plot[smooth,domain=-2:2] (\x, {(\x)^2});
\draw[black, line width = 0.50mm] plot[smooth,domain= -2:2] (\y, {(\y)^2});
\end{tikzpicture}
\end{document}
답변1
추가하다 variable=\y
. 결과는 분명히 똑같습니다.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[domain=0:2, scale = 0.75]
\draw(-4,0)--(4,0);
\draw (0,-4)--(0,4);
%\draw[black, line width = 0.50mm] plot[smooth,domain=-2:2] (\x, {(\x)^2});
\draw[black, line width = 0.50mm] plot[smooth,domain= -2:2,variable=\y] (\y, {(\y)^2});
\end{tikzpicture}
\end{document}
플롯 변수를 호출할 수도 \CuteFurryRodent
있으며 여전히 다음과 같은 결과를 얻을 수 있습니다.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[domain=0:2, scale = 0.75]
\draw(-4,0)--(4,0);
\draw (0,-4)--(0,4);
\draw[black, line width = 0.50mm]
plot[smooth,domain= -2:2,variable=\CuteFurryRodent] (\CuteFurryRodent, {(\CuteFurryRodent)^2});
\end{tikzpicture}
\end{document}
x와 y의 역할을 바꾸고 싶을 수도 있습니다.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[domain=0:2, scale = 0.75]
\draw(-4,0)--(4,0);
\draw (0,-4)--(0,4);
\draw[black, line width = 0.50mm] plot[smooth,domain=-2:2] (\x, {(\x)^2});
\draw[blue,dashed, line width = 0.50mm] plot[smooth,domain= -2:2,variable=\y]
( {(\y)^2},\y);
\end{tikzpicture}
\end{document}
여기서도 사용할 수 있습니다 parabola bend
.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[domain=0:2, scale = 0.75]
\draw(-4,0)--(4,0);
\draw (0,-4)--(0,4);
\draw[black, line width = 0.50mm] (-2,4) parabola bend (0,0) (2,4);
\draw[blue,dashed, line width = 0.50mm,rotate=-90] (-2,4) parabola bend (0,0) (2,4);
\end{tikzpicture}
\end{document}