我想用 tikz 重现上面的图片: 我不知道如何将箭头放入圆柱体内部,因为圆柱体的顶部与其余部分不匹配……我的代码如下:
\documentclass[tikz,border=12pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usetikzlibrary{arrows,shapes,positioning,shadows,trees}
% isometric axes
\pgfmathsetmacro\xx{1/sqrt(2)}
\pgfmathsetmacro\xy{1/sqrt(6)}
\pgfmathsetmacro\zz{sqrt(2/3)}
\tikzset{isometric/.style={x={(-\xx cm,-\xy cm)},y={(\xx cm,-\xy cm)},z={(0cm,\zz cm)}}}
% parameters
\def\H {4} % total height
\def\R {1} % outer radius
\tikzset
{
outer/.style={fill=gray!10},
top/.style= {fill=gray!40},
}
\begin{document}
\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=1,xscale=1, isometric,line join=round,line cap=round]~
\draw [-latex](0,0,-1) -- (0,0,\H + 1);
\draw[outer] (0,-\R/2,0) arc (-45:135:\R) --++ (0,0,\H) arc (135:-45:\R) --++ (0,0,-\H) -- cycle;
\draw[top] (-\R/2,0,\H) circle (\R);
\end{tikzpicture}
\end{document}
答案1
也许这样的东西可以满足您的需要?
\documentclass[tikz,border=12pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usetikzlibrary{arrows,shapes,positioning,shadows,trees}
\usetikzlibrary{3d} % <--- use of canvas and rotation
% isometric axes
\pgfmathsetmacro\xx{1/sqrt(2)}
\pgfmathsetmacro\xy{1/sqrt(6)}
\pgfmathsetmacro\zz{sqrt(2/3)}
\tikzset{isometric/.style={x={(-\xx cm,-\xy cm)},y={(\xx cm,-\xy cm)},z={(0cm,\zz cm)}}}
% parameters
\def\H {4} % total height
\def\R {1} % outer radius
\tikzset
{
outer/.style={fill=gray!10, fill opacity = 0.5}, % Adding opacity option
top/.style= {fill=gray!40, fill opacity = 0.5},
}
\begin{document}
% arrows inside cylinder
\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=1,xscale=1, isometric,line join=round,line cap=round]
\foreach \i in {0,45,...,360}{
\draw (\i:0.7) + (0,0,-1)-- +(0,0,\H) coordinate(\i); % arrows main body
}
\draw[outer] (-45:\R) arc (-45:135:\R) --++ (0,0,\H) arc (135:-45:\R) -- cycle;
\draw[top] (0,0,\H) circle (\R);
\foreach \i in {0,45,...,360}{
\draw[-latex] (\i)node{.} --+ (0,0,1); % arrows head
}
\end{tikzpicture}
% arrows around cylinder
\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=1,xscale=1, isometric,line join=round,line cap=round]
\foreach \i in {135,180,...,315}{
\draw[rotate around z=\i,canvas is xz plane at y=0, -latex, rounded corners, blue]
(0.7,-1) -- (0.7,-0.2) -- (\R+0.2,-0.2) -- (\R+0.2,\H+0.2) -- (0.7,\H+0.2) --+ (0,1);
}
\draw[outer] (-45:\R) arc (-45:135:\R) --++ (0,0,\H) arc (135:-45:\R) -- cycle;
\draw[top] (0,0,\H) circle (\R);
\foreach \i in {0,45,...,90}{
\draw[rotate around z=\i,canvas is xz plane at y=0, -latex, rounded corners, blue]
(0.7,-1) -- (0.7,-0.2) -- (\R+0.2,-0.2) -- (\R+0.2,\H+0.2) -- (0.7,\H+0.2) --+ (0,1);
}
\end{tikzpicture}
答案2
我得出的结论是,圆柱体内线条的表示使得图像的解释令人困惑。所以我选择了一种最简单的表示方式:
\documentclass[border=0.2cm]{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{arrows}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[scale=1.5]
\node[cylinder, draw = black, cylinder uses custom fill, cylinder body fill = gray!10, cylinder end fill = gray!40, aspect = 0.2, line width=0.1mm, shape border rotate = 90, scale = 8] (c) at (0,0) {};
\draw [-stealth, red, line width=0.25mm](0, -1.2) --++ (0,2.6);
\draw [-stealth, red, line width=0.25mm](0.3, -1.2) --++ (0,2.6);
\draw [-stealth, red, line width=0.25mm](0.6, -1.2) --++ (0,2.6);
\draw [-stealth, red, line width=0.25mm](0.9, -1.2) --++ (0,2.6);
\draw [-stealth, red, line width=0.25mm](-0.3, -1.2) --++ (0,2.6);
\draw [-stealth, red, line width=0.25mm](-0.6, -1.2) --++ (0,2.6);
\draw [-stealth, red, line width=0.25mm](-0.9, -1.2) --++ (0,2.6);
\end{tikzpicture}
\caption{Conducting (or normal) state.}
\label{subfig:cond_st}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}[scale=1.5]
\node[cylinder, draw = black, cylinder uses custom fill, cylinder body fill = gray!10, cylinder end fill = gray!40, aspect = 0.2, line width=0.1mm, shape border rotate = 90, scale=8] (c) at (0,0) {};
\draw [-stealth, red, line width=0.25mm, rounded corners](-0.9, -1.2) --++ (0,2.6);
\draw [-stealth, red, line width=0.25mm, rounded corners] (-0.6, -1.2) --++ (0,0.4) --++(-0.25,0.15) --++ (0,1.6) --++ (0.2,0.15) --++ (0,0.3);
\draw [-stealth, red, line width=0.25mm, rounded corners] (-0.3, -1.2) --++ (0,0.4) --++(-0.45,0.15) --++ (0,1.6) --++ (0.40,0.15) --++ (0,0.3);
\draw [-stealth, red, line width=0.25mm, rounded corners] (0.3, -1.2) --++ (0,0.4) --++(0.45,0.15) --++ (0,1.6) --++ (-0.40,0.15) --++ (0,0.3);
\draw [-stealth, red, line width=0.25mm, rounded corners] (0.6, -1.2) --++ (0,0.4) --++(0.25,0.15) --++ (0,1.6) --++ (-0.2,0.15) --++ (0,0.3);
\draw [-stealth, red, line width=0.25mm, rounded corners](0.9, -1.2) --++ (0,2.6);
\draw [-stealth, red, line width=0.25mm, rounded corners] (-0.55, -0.45) arc (-100:-80:3.25);
\draw [-stealth, red, line width=0.25mm, rounded corners] (0.55, -0.30) arc (80:100:3.25);
\draw [-stealth, red, line width=0.25mm, rounded corners] (-0.55, 0.1) arc (-100:-80:3.25);
\draw [-stealth, red, line width=0.25mm, rounded corners] (0.55, 0.25) arc (80:100:3.25);
\draw [-stealth, red, line width=0.25mm, rounded corners] (-0.55, 0.65) arc (-100:-80:3.25);
\draw [-stealth, red, line width=0.25mm, rounded corners] (0.55, 0.78) arc (80:100:3.25);
\end{tikzpicture}
\caption{Superconducting state.}
\label{subfig:sc_st}
\end{figure}
\end{document}
我愿意接受有关改进我的代码的建议。