我想要绘制两个参数曲线及其图像,方式如下:第一个为蓝色,第二个为红色:
\begin{tikzpicture}[trig format=rad,scale=3,
declare function={%
gammarx(\r,\t)=(t);
gammary(\r,\t)=(r);}]
\foreach \r in {1,2,3,4,5}
{\draw plot[smooth,samples=150, variable=\t,domain=-10:10]
({gammarx(\r,\t)},{gammary(\r,\t)});}
\end{tikzpicture}
\begin{tikzpicture}[trig format=rad,scale=3,
declare function={%
gammarx(\r,\t)=(r);
gammary(\r,\t)=(t);}]
\foreach \r in {-1,-2,-3,1,2,3}
{\draw plot[smooth,samples=150, variable=\t,domain=0:10]
({gammarx(\r,\t)},{gammary(\r,\t)});}
\end{tikzpicture}
然后将它们的图像绘制在函数 f 下,也位于同一轴上。其中 f 如下所示
\begin{tikzpicture}[trig format=rad,scale=3,
declare function={%
gammarx(\r,\t)=(\t*\t*(\r*\r+1)-1)/%
(\t*\t*(\r*\r+1)+2*\r*\t+1);
gammary(\r,\t)=(-2*\t)/(\t*\t*(\r*\r+1)+2*\r*\t+1);}]
\foreach \r in {1,2,3,4,10}
{\draw plot[smooth,samples=150, variable=\t,domain=0:10]
({gammarx(\r,\t)},{gammary(\r,\t)});}
\end{tikzpicture}
\begin{tikzpicture}[trig format=rad,scale=3,
declare function={%
gammarx(\r,\t)=(\t*\t*(\r*\r+1)-1)/%
(\t*\t*(\r*\r+1)+2*\r*\t+1);
gammary(\r,\t)=(2*\t)/(\t*\t*(\r*\r+1)+2*\r*\t+1);}]
\foreach \r in {1,2,3,4,10}
{\draw plot[smooth,samples=150, variable=\t,domain=0:10]
({gammarx(\r,\t)},{gammary(\r,\t)});}
\end{tikzpicture}
答案1
如果参数图通过交换 x 和 y 的角色来关联,则只需交换图的参数中的条目即可。否则,我只会将事物放入范围内,并稍微更改一些比例和域,以避免图变得太大。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,bending}
\begin{document}
\begin{tikzpicture}[trig format=rad]
\begin{scope}[local bounding box=L,scale=0.5,declare function={%
gammarx(\r,\t)=(\t);
gammary(\r,\t)=(\r);}]
\foreach \r in {1,2,3,4,5}
{\draw[red] plot[smooth,samples=2, variable=\t,domain=-5:5]
({gammarx(\r,\t)},{gammary(\r,\t)});}
\foreach \r in {-1,-2,-3,1,2,3}
{\draw[blue] plot[smooth,samples=2, variable=\t,domain=0:6]
({gammary(\r,\t)},{gammarx(\r,\t)});}
\end{scope}
%
\begin{scope}[local bounding box=R,xshift=7cm,yshift=2cm,scale=3,
declare function={%
gammarx(\r,\t)=(\t*\t*(\r*\r+1)-1)/%
(\t*\t*(\r*\r+1)+2*\r*\t+1);
gammary(\r,\t)=(-2*\t)/(\t*\t*(\r*\r+1)+2*\r*\t+1);}]
\foreach \r in {1,2,3,4,10}
{\draw[red] plot[smooth,samples=151, variable=\t,domain=0:10]
({gammarx(\r,\t)},{gammary(\r,\t)});}
\foreach \r in {1,2,3,4,10}
{\draw[blue] plot[smooth,samples=151, variable=\t,domain=0:10]
({gammary(\r,\t)},{gammarx(\r,\t)});}
\end{scope}
%
\draw[-{Stealth[bend]},semithick] (L.east) to[bend right,edge label={$f$}] (L-|R.west);
\end{tikzpicture}
\end{document}
如果您想添加轴线等,我建议使用pgfplots
。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usetikzlibrary{arrows.meta,bending}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{trig format plots=rad,width=6.5cm,axis lines=middle,
xlabel={$x$},ylabel={$y$}}
\begin{axis}[name=L,declare function={%
gammarx(\r,\t)=(\t);
gammary(\r,\t)=(\r);}]
\pgfplotsinvokeforeach{1,2,3,4,5}
{\addplot[red,smooth,samples=2, variable=\t,domain=-5:5]
({gammarx(#1,\t)},{gammary(#1,\t)});}
\pgfplotsinvokeforeach{-1,-2,-3,1,2,3}
{\addplot[blue,smooth,samples=2, variable=\t,domain=0:6]
({gammary(#1,\t)},{gammarx(#1,\t)});}
\end{axis}
%
\begin{axis}[name=R,xshift=7cm,
declare function={%
gammarx(\r,\t)=(\t*\t*(\r*\r+1)-1)/%
(\t*\t*(\r*\r+1)+2*\r*\t+1);
gammary(\r,\t)=(-2*\t)/(\t*\t*(\r*\r+1)+2*\r*\t+1);}]
\pgfplotsinvokeforeach{1,2,3,4,10}
{\addplot[red,smooth,samples=151, variable=\t,domain=0:10]
({gammarx(#1,\t)},{gammary(#1,\t)});}
\pgfplotsinvokeforeach{1,2,3,4,10}
{\addplot[blue,smooth,samples=151, variable=\t,domain=0:10]
({gammary(#1,\t)},{gammarx(#1,\t)});}
\end{axis}
%
\draw[-{Stealth[bend]},semithick] (L.east) to[bend left,edge label={$f$}] (L-|R.west);
\end{tikzpicture}
\end{document}