这是一个后续问题箭筒图中的替代颜色
我怎样才能剪切绘制圆圈的区域(而不是绘制圆圈):
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{
compat=newest,
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
domain=-10:10,
samples=20,
xmin=-10,xmax=10,
ymin=-10,ymax=10,
zmin=-20,zmax=20,
point meta=z,
height=20cm,
width=15cm,
view={45}{45}
]
\pgfplotsinvokeforeach{-20,0,20}{
\pgfplotsset{cycle list shift=1}
\draw (0,0,#1) circle (7);
\addplot3[quiver,-stealth,
quiver={
u={-y/(x^2+y^2)},
v={x/(x^2+y^2)},
w={0},
scale arrows=10,
colored=mapped color
},
]
(x,y,#1);
}
\draw[ultra thick] (0,0,-20) -- (0,0,20);
%
\end{axis}
\end{tikzpicture}
\end{document}
答案1
这是一种方法。使用scope
s 和参数图来绘制剪切路径。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{
compat=newest,
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
domain=-10:10,
samples=20,
xmin=-10,xmax=10,
ymin=-10,ymax=10,
zmin=-20,zmax=20,
point meta=z,
height=20cm,
width=15cm,
view={45}{45}
]
\pgfplotsinvokeforeach{-20,0,20}{
\begin{scope}
\clip plot[smooth cycle,variable=\t,domain=0:355] ({7*cos(\t)},{7*sin(\t)},#1);
\addplot3[quiver,-stealth,
quiver={
u={-y/(x^2+y^2)},
v={x/(x^2+y^2)},
w={0},
scale arrows=10,
colored=mapped color
},
]
(x,y,#1);
\end{scope}
}
\draw[ultra thick] (0,0,-20) -- (0,0,20);
%
\end{axis}
\end{tikzpicture}
\end{document}