1

I want to reproduce the above picture with tikz: enter image description here I don't know how to put the arrows inside the cylinder when they cross it. And the top of the cylinder does not match with the rest... My code is below:

\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}

And the result: enter image description here

1
  • Concerning the problem of your cylinder, the beginning of your 'outer' path is not correct. I suggest using polar coordinates : \draw[outer] (-45:\R) arc (-45:135:\R) --++ (0,0,\H) arc (135:-45:\R) -- cycle; If you want to see the arrows, you can use the option fill opacity=0.5. But you will need to draw the top in several pieces.
    – Tobard
    Commented Jan 10, 2022 at 16:10

2 Answers 2

2

Maybe something like this could suit your needs ?

\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}

enter image description here      enter image description here

3
  • How can I put the arrows leveled as the first picture that I post? Commented Jan 10, 2022 at 21:32
  • I've added an example of what you can do. It uses the 3d library.
    – Tobard
    Commented Jan 11, 2022 at 8:24
  • Check my new answer :) Commented Jan 11, 2022 at 21:42
0

I came to the conclusion that the representation of the lines inside the cylinder makes the interpretation of the image confusing. So I opted for a simplest representation:

\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}

enter image description here enter image description here

I am open to suggestions for improving my code.

1
  • I agree this is much more clear. You could use a global style setting to avoid repeating arrows style options and being able to change all at once.
    – Tobard
    Commented Jan 12, 2022 at 8:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .