答案1
假设你正在谈论标准偶极子,其功能类似于sin(theta)^1
(按照 pgfplots 的惯例,变为cos(theta)^2
),您可以使用 pgfplots 的 3d 和极坐标图功能。对于子图,我选择了随机答案因为它看起来足够灵活,可以满足对齐要求。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{width=8cm,compat=1.16}
\usepgfplotslibrary{polar}
\usepackage{subcaption}
\usepackage{floatrow} % adapted from https://tex.stackexchange.com/a/389970/121799
\begin{document}
\begin{figure}[htb]
\floatsetup{valign=t, heightadjust=all}
\ffigbox{%
\begin{subfloatrow}
\ffigbox{\begin{tikzpicture}
\begin{axis}[view/h=45,axis lines = none,unit vector ratio=1 1 1]
\addplot3[domain=0:360,domain y=0:360,surf,
z buffer=sort]
({(sin(x+90)*sin(x+90))*cos(y)},
{(sin(x+90)*sin(x+90))*sin(y)},
{(sin(x+90)*sin(x+90))*sin(x)});
\end{axis}
\path(current bounding box.south west) rectangle (current bounding box.north
east);
\end{tikzpicture}}{\caption{3d plot.\label{fig:3dplot}}}
\ffigbox{\begin{tikzpicture}
\begin{polaraxis}[axis lines = none]
\addplot[domain=0:360,samples=73,smooth] (x+90,{sin(x)*sin(x)});
\end{polaraxis}
\end{tikzpicture}}{\caption{Polar plot.\label{fig:polarplot}}}
\end{subfloatrow}}
{\caption{Dipole.}\label{fig:Dipole}}
\end{figure}
\end{document}
如果您想要单色网格而不是 3D 图,这里有第二个选项及其说明。
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{pgfplots}
\pgfplotsset{width=8cm,compat=1.16}
\usepgfplotslibrary{polar}
\usepackage{subcaption}
\usepackage{floatrow} % adapted from https://tex.stackexchange.com/a/389970/121799
\begin{document}
\begin{figure}[htb]
\floatsetup{valign=c, heightadjust=all}
\ffigbox{%
\begin{subfloatrow}
\ffigbox{\begin{tikzpicture}
\begin{axis}[view/h=45,axis lines = none,unit vector ratio=1 1 1]
\addplot3[domain=0:360,domain y=0:360,samples=31,
colormap/blackwhite,surf,%mesh,point meta=1, %<-if you want a mesh
z buffer=sort]
({(sin(x+90)*sin(x+90))*cos(y)},
{(sin(x+90)*sin(x+90))*sin(y)},
{(sin(x+90)*sin(x+90))*sin(x)});
\end{axis}
\path(current bounding box.south west) rectangle (current bounding box.north
east);
\end{tikzpicture}}{\caption{3d plot.\label{fig:3dplot}}}
\ffigbox{\begin{tikzpicture}
\begin{polaraxis}[axis lines = none]
\addplot[domain=0:360,samples=73,smooth] (x+90,{sin(x)*sin(x)});
\end{polaraxis}
\draw[-stealth] ([yshift=2cm]current axis.south) -- ([yshift=-2cm]current axis.north);
\draw[-stealth] (current axis.west) -- (current axis.east);
\end{tikzpicture}}{\caption{Polar plot.\label{fig:polarplot}}}
\end{subfloatrow}}
{\caption{Dipole.}\label{fig:Dipole}}
\end{figure}
\end{document}
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{pgfplots}
\pgfplotsset{width=8cm,compat=1.16}
\usepgfplotslibrary{polar}
\usepackage{subcaption}
\usepackage{floatrow} % adapted from https://tex.stackexchange.com/a/389970/121799
\begin{document}
\begin{figure}[htb]
\floatsetup{valign=c, heightadjust=all}
\ffigbox{%
\begin{subfloatrow}
\ffigbox{\begin{tikzpicture}
\begin{axis}[view/h=45,axis lines = none,unit vector ratio=1 1 1]
\addplot3[domain=0:360,domain y=0:360,samples=31,
mesh,point meta=1, %<-if you want a mesh
z buffer=sort]
({(sin(x+90)*sin(x+90))*cos(y)},
{(sin(x+90)*sin(x+90))*sin(y)},
{(sin(x+90)*sin(x+90))*sin(x)});
\end{axis}
\path(current bounding box.south west) rectangle (current bounding box.north
east);
\end{tikzpicture}}{\caption{3d plot.\label{fig:3dplot}}}
\ffigbox{\begin{tikzpicture}
\begin{polaraxis}[axis lines = none]
\addplot[domain=0:360,samples=73,smooth] (x+90,{sin(x)*sin(x)});
\end{polaraxis}
\draw[-stealth] ([yshift=2cm]current axis.south) -- ([yshift=-2cm]current axis.north);
\draw[-stealth] (current axis.west) -- (current axis.east);
\end{tikzpicture}}{\caption{Polar plot.\label{fig:polarplot}}}
\end{subfloatrow}}
{\caption{Dipole.}\label{fig:Dipole}}
\end{figure}
\end{document}
另一个版本。point meta
适当设置几乎可以实现任何阴影。
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{pgfplots}
\pgfplotsset{width=8cm,compat=1.16}
\usepgfplotslibrary{polar}
\usepackage{subcaption}
\usepackage{floatrow} % adapted from https://tex.stackexchange.com/a/389970/121799
\begin{document}
\begin{figure}[htb]
\floatsetup{valign=c, heightadjust=all}
\ffigbox{%
\begin{subfloatrow}
\ffigbox{\begin{tikzpicture}
\begin{axis}[view/h=45,axis lines = none,unit vector ratio=1 1 1]
\addplot3[domain=0:360,domain y=0:360,samples=31,
point meta=sqrt(x^2+y^2),
colormap/blackwhite,surf,%mesh,point meta=1, %<-if you want a mesh
z buffer=sort]
({(sin(x+90)*sin(x+90))*cos(y)},
{(sin(x+90)*sin(x+90))*sin(y)},
{(sin(x+90)*sin(x+90))*sin(x)});
\end{axis}
\path(current bounding box.south west) rectangle (current bounding box.north
east);
\end{tikzpicture}}{\caption{3d plot.\label{fig:3dplot}}}
\ffigbox{\begin{tikzpicture}
\begin{polaraxis}[axis lines = none]
\addplot[domain=0:360,samples=73,smooth] (x+90,{sin(x)*sin(x)});
\end{polaraxis}
\draw[-stealth] ([yshift=2cm]current axis.south) -- ([yshift=-2cm]current axis.north);
\draw[-stealth] (current axis.west) -- (current axis.east);
\end{tikzpicture}}{\caption{Polar plot.\label{fig:polarplot}}}
\end{subfloatrow}}
{\caption{Dipole.}\label{fig:Dipole}}
\end{figure}
\end{document}
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{pgfplots}
\pgfplotsset{width=8cm,compat=1.16}
\usepgfplotslibrary{polar}
\usepackage{subcaption}
\usepackage{floatrow} % adapted from https://tex.stackexchange.com/a/389970/121799
\begin{document}
\begin{figure}[htb]
\floatsetup{valign=c, heightadjust=all}
\ffigbox{%
\begin{subfloatrow}
\ffigbox{\begin{tikzpicture}
\begin{axis}[view/h=70,axis lines = none,unit vector ratio=1 1 1]
\addplot3[domain=0:360,domain y=0:360,samples=31,
point meta=sqrt(x^2+y^2),
colormap/blackwhite,surf,%mesh,point meta=1, %<-if you want a mesh
z buffer=sort]
({(sin(x+90)*sin(x+90))*cos(y)},
{(sin(x+90)*sin(x+90))*sin(y)},
{(sin(x+90)*sin(x+90))*sin(x)});
\pgfplotsinvokeforeach{0,1,...,7}{
\draw[-latex] ({2*cos(#1*45)},{2*sin(#1*45)},0)
-- ({4*cos(#1*45)},{4*sin(#1*45)},0);
\addplot3[samples=81,samples y=1,domain=0:1260,color=blue,thin]
({(x/720+2)*cos(#1*45)},{(x/720+2)*sin(#1*45)},{0.25*sin(x)});
\addplot3[samples=81,samples y=1,domain=0:1260,color=red,thin]
({(x/720+2)*cos(#1*45)-0.25*sin(#1*45)*sin(x)},{(x/720+2)*sin(#1*45)+0.25*cos(#1*45)*sin(x)},{0});
}
\end{axis}
\path(current bounding box.south west) rectangle (current bounding box.north
east);
\end{tikzpicture}}{\caption{3d plot.\label{fig:3dplot}}}
\ffigbox{\begin{tikzpicture}
\begin{polaraxis}[axis lines = none]
\addplot[domain=0:360,samples=73,smooth] (x+90,{sin(x)*sin(x)});
\end{polaraxis}
\draw[-stealth] ([yshift=2cm]current axis.south) -- ([yshift=-2cm]current axis.north);
\draw[-stealth] (current axis.west) -- (current axis.east);
\end{tikzpicture}}{\caption{Polar plot.\label{fig:polarplot}}}
\end{subfloatrow}}
{\caption{Dipole.}\label{fig:Dipole}}
\end{figure}
\end{document}
如果您还有其他要求,我可以请您提出一个新问题吗?毕竟,提问是免费的。
答案2
和你一样,我对绘制赫兹偶极子辐射图的辐射图非常感兴趣,我已经测试了 user121799 提供的解决方案,但它对我来说效果不太好:它有点问题,而且编译需要很长时间。
然后我决定用 tikz-3dplot 包修改 user121799 的解决方案。第一个片段是关于功率辐射图的,其极坐标方程是 sin(θ)^2
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{pgfplots}
\pgfplotsset{width=8cm,compat=1.16}
\usepgfplotslibrary{polar}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{135}
\begin{figure}[]
\begin{center}
\begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords, fill opacity=.7]
\pgfsetlinewidth{.4pt}
\tdplotsphericalsurfaceplot{72}{24}%
{sin(\tdplottheta)^2}{black}{blue}%
{\draw[color=black,thick,->] (0,0,0) -- (2,0,0) node[anchor=north east]{$x$};}%
{\draw[color=black,thick,->] (0,0,0) -- (0,2,0) node[anchor=north west]{$y$};}%
{\draw[color=black,thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};}
\end{tikzpicture}
\caption{Power radiation Hertzian dipole 3d}\label{fig:3dplot_radiation_dipole}
\end{center}
\end{figure}
\begin{figure}[]
\begin{center}
\begin{tikzpicture}
\begin{polaraxis}[axis lines = none]
\addplot[domain=0:360,samples=73,smooth] (x+90,{sin(x)^2});
\end{polaraxis}
\draw[-stealth] ([yshift=1.5cm]current axis.south) -- ([yshift=-1.5cm]current axis.north) node[anchor=north,yshift=1cm]{$z$};
\draw[-stealth] (current axis.west) -- (current axis.east) node[anchor=west]{$x$};
\end{tikzpicture}
\caption{Power radiation Hertzian dipole in x-z plane}
\end{center}
\end{figure}
\end{document}
如果你对辐射模式(而不是功率)感兴趣,在许多注释中(就像意大利语中的那样)可以发现它的方程为|sin(θ)|,则代码变成:
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{pgfplots}
\pgfplotsset{width=8cm,compat=1.16}
\usepgfplotslibrary{polar}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{135}
\begin{figure}[]
\begin{center}
\begin{tikzpicture}[scale=2,line join=bevel,tdplot_main_coords, fill opacity=.7]
\pgfsetlinewidth{.4pt}
\tdplotsphericalsurfaceplot[parametricfill]{72}{24}%
{abs(sin(\tdplottheta))}{black}{\tdplotphi}%
{\draw[color=black,thick,->] (0,0,0) -- (2,0,0) node[anchor=north east]{$x$};}%
{\draw[color=black,thick,->] (0,0,0) -- (0,2,0) node[anchor=north west]{$y$};}%
{\draw[color=black,thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};}
\end{tikzpicture}\caption{radiation pattern Hertzian dipole 3d}
\end{center}
\end{figure}
\begin{figure}[]
\begin{center}
\begin{tikzpicture}
\begin{polaraxis}[axis lines = none]
\addplot[domain=0:360,samples=73,smooth] (x+90,{abs(sin(x))});
\end{polaraxis}
\draw[-stealth] ([yshift=1.5cm]current axis.south) -- ([yshift=-1.5cm]current axis.north) node[anchor=north,yshift=1cm]{$z$};
\draw[-stealth] (current axis.west) -- (current axis.east) node[anchor=west]{$x$};
\end{tikzpicture}
\caption{radiation pattern Hertzian dipole in x-z plane}
\end{center}
\end{figure}
\end{document}
最后这张 3D 图是彩色的,因为我喜欢它,你可以在tikz-3dplot 文档我希望
我能帮助那些像我一样面临问题的人