4

I'm trying to graph the same figure using latex,

Any idea where to start?

enter image description here

Update, I tried the following code .. it is not near what I want

   \documentclass[border=10pt,tikz]{standalone}
\usepackage{xcolor}
\definecolor{lava}{rgb}{0.81, 0.06, 0.13}
\definecolor{myblue}{rgb}{0.0, 0.30, 0.60}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{positioning}
\usepackage{rotating}
\begin{document}

\begin{tikzpicture} \draw [fill=white, fill opacity=.05,line width=0.0mm] (180:5mm) coordinate (a) -- ++(0,3mm) coordinate (b) arc (180:360:5mm and 1.75mm) coordinate (d) -- (a -| d) coordinate (c) ; \draw [fill=white, fill opacity=.05,line width=0.0mm] (0,0) coordinate (t) circle (5mm and 1.75mm); \draw [line width=0.0mm] (d) arc (0:180:5mm and 1.75mm);

\draw [fill=white, fill opacity=.05,line width=0.0mm]

(-.5mm,0.25) coordinate (a2) -- ++(0,4mm) coordinate (b2) arc (180:360:.5mm and 0.15mm) coordinate (d2) -- (a2 -| d2) coordinate (c2) arc (0:180:.5mm and 0.15mm); \draw [fill=white, fill opacity=.5,line width=0.0mm] (0,0.25) coordinate (t) circle (.5mm and 0.15mm); \draw [dashed,line width=0.0mm] (d2) arc (0:180:.5mm and 0.15mm);

\draw [line width=0.0mm] (0,0) coordinate (T) circle (7.5mm and 2.625mm); \draw [fill=myblue, fill opacity=.05,line width=0.0mm] (180:7.5mm) coordinate (A) -- ++(0,-5.5mm) coordinate (B) node [midway, right, inner sep=1pt] {} arc (180:360:7.5mm and 2.625mm) coordinate (D) -- (A -| D) coordinate (C) arc (0:180:7.5mm and 2.625mm); \draw [line width=0.0mm] (D) arc (0:180:7.5mm and 2.625mm);

-- (T) node [midway, right, anchor=west, fill=white, inner sep=.5pt] {} node [anchor=center, circle, draw, solid, inner sep=.5pt, fill=white] {} edge [solid, -Latex] node [right, pos=1] {} ++(0,5mm) ; \end{tikzpicture}

\end{document}

Any adjustments to make it look better is appreciated.

Diana
  • 1,285
  • 7
  • 12
  • This is a quite plain drawing that you may be able to achieve layer by layer, with some opacity tunings. Did you try anything yet? – SebGlav Jan 15 '21 at 17:52

1 Answers1

8

Probably the best solution is to use the shapes.geometric library, and do something like what is indicated here: More on "Cylinder shading with pgf TiKZ".

However, recycling a previous drawing of mine involving cylinders, I can offer you an alternative, something like this:

\documentclass[border=2mm]{standalone}    
\usepackage    {ifthen}
\usepackage    {tikz}
\usetikzlibrary{calc}

\newcommand{\cylinder}[5] % center, radius (y-axis), height (to the right), color, opacity { \pgfmathsetmacro\r {0.5*#2} % radius (x-axis) \coordinate (C1) at #1; % center, left ellipse \coordinate (N1) at ($(C1)+(0,#2)$); % north, left ellipse
\coordinate (NW1) at ($(C1)+(-\r,#2)$); % north west, left ellipse \coordinate (W1) at ($(C1)-(\r,0)$); % west, left ellipse
\coordinate (S1) at ($(C1)-(0,#2)$); % south, left ellipse \coordinate (P1) at ($(W1)!0.1!(NW1)$); % point for shading \coordinate (Q1) at ($(W1)!0.2!(NW1)$); % another point for shading \coordinate (C2) at ($(C1)+(#3,0)$); % center, right ellipse \coordinate (N2) at ($(N1)+(#3,0)$); % ... \coordinate (S2) at ($(S1)+(#3,0)$); \coordinate (P2) at ($(P1)+(#3,0)$); \ifthenelse {\equal{#3}{0}} % if height is 0 {} % then do nothing { % else... \begin{scope} \clip (N1) arc (90:270:\r cm and #2 cm) -- (S2) -- (S2) arc (270:90:\r cm and #2 cm) -- cycle; \shade[top color=white, bottom color=#4!65,fill opacity=#5] (S2) rectangle (P1); \shade[top color=#4!55, bottom color=white,fill opacity=#5] (N2) rectangle (Q1); \fill[white, opacity=#5] (P2) rectangle (Q1); \end{scope} \draw[#4] (N2) -- (N1) arc (90:270:\r cm and #2 cm) -- (S2); } \draw[#4,fill=#4!12.5,opacity=#5] (C2) ellipse (\r cm and #2 cm); }

\begin{document} \begin{tikzpicture}[scale=2,line cap=round,line join=round] \cylinder{(0,0)}{0.75}{2}{blue} {1}; \cylinder{(0,0)}{1} {2}{black}{0.75}; \cylinder{(2,0)}{0.75}{1}{blue} {1}; \cylinder{(3,0)}{0.1} {0}{red} {1}; \fill(3,0) circle (0.25pt); \draw[very thin,dashed] (2,1) -- (3.5,1); \draw[very thin,dashed] (3,0.75) -- (4,0.75); \draw[very thin,dashed] (3,0.1) -- (3.6,0.1); \draw[very thin,dashed] (3,0) -- (4,0); \draw[-latex] (3.5,1) node [above right] {Refractive index} -- (6,1); \draw[red!80!black] (3.7,1) |- (3.6,0.75) |- (4,0.1) -- (4,0); \node at (4,0.875) [right] {Coating}; \node at (4,0.425) [right] {Cladding}; \node at (4,0.05) [right] {Core}; \end{tikzpicture}
\end{document}

This is the drawing: enter image description here

Juan Castaño
  • 28,426