LaTeX forum ⇒ Graphics, Figures & Tablesdraw figure with Tikz

Information and discussion about graphics, figures & tables in LaTeX documents.
beningermany
Posts: 10
Joined: Tue Aug 21, 2018 5:55 pm

draw figure with Tikz

Postby beningermany » Thu Aug 23, 2018 11:17 am

Hi, I am just beginning to learn Tikz/PGF. However, I have trouble drawing some complicated figures. Is there anyone who can give me some tips?

the geometry of the top eclipse (or circle) is divided by 4 or 8 capacitors (in the symbol as || vertical or horizontal, depends on where it is located. ) It should be either in 2 dimensional or 3 dimensional drawings of the final figures. Any hint will be appreciated.
Attachments
birdcage.png
birdcage.png (25.1 KiB) Viewed 488 times

User avatar
Stefan Kottwitz
Site Admin
Posts: 9192
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Thu Aug 23, 2018 1:30 pm

Hi,

here is a start. I define coordinates using polar coordinates. Then I draw lines and capacitor nodes. For now, I used normal nodes. Capacitors could be drawn manually, such as TikZ double lines.

  1. \documentclass[border=10pt]{standalone}
  2. \usepackage{tikz}
  3. \usetikzlibrary{positioning}
  4. \begin{document}
  5. \begin{tikzpicture}[font=\scriptsize]
  6. \def\height{5}
  7. \def\width{3}
  8. \draw (0, 0) ellipse (\width cm and 1 cm);
  9. \draw (0,-\height ) ellipse (\width cm and 1 cm);
  10. \foreach \i in { 1,...,8 } {
  11. \coordinate (top\i) at (45*\i+138:\width cm and 1cm);
  12. \coordinate [below = \height cm of top\i] (bottom\i);
  13. \coordinate (capacitor-top\i) at (45*\i+158.5:\width cm and 1cm);
  14. \coordinate [below = \height cm of capacitor-top\i]
  15. (capacitor-bottom\i);
  16. }
  17. \foreach \i in { 1,...,5 }
  18. \draw (top\i) -- (bottom\i);
  19. \foreach \i in { 6,...,8 }
  20. \draw [dashed] (top\i) -- (bottom\i);
  21. \foreach \i in { 1,...,8 } {
  22. \node [circle, draw, fill=white, inner sep=1pt]
  23. at (capacitor-top\i) {C};
  24. \node [circle, draw, fill=white, inner sep=1pt]
  25. at (capacitor-bottom\i) {C};
  26. }
  27. \end{tikzpicture}
  28. \end{document}


cylinder.png
cylinder.png (23.58 KiB) Viewed 481 times


Stefan
Site admin

beningermany
Posts: 10
Joined: Tue Aug 21, 2018 5:55 pm

Postby beningermany » Thu Aug 23, 2018 1:41 pm

I found another figure. the circuits ( b and d) I could make it. here I want to show the code.

Thank you very much for your help. I am still learning node and coordinate. I will show my codes later on.
The codes below is for high pass or low pass circuit.
\documentclass[tikz, margin=15px]{standalone}
\usepackage{color,graphicx,circuitikz}
\usepackage[load-configurations=version-1]{siunitx}
\usetikzlibrary{arrows}
\begin{document}

\begin{circuitikz}[scale=1]

\draw

(0,4)

to [L, l=\small{$L_{j-1,j-1}$}] (4,4)
to [L, *-*,l=\small{$L_{j,j}$}] (8,4)
to [L, l=\small{$L_{j+1,j+1}$}] (12,4)

(0,0)
to [L, l_=\small{$L_{j-1,j-1}$}] (4,0)
to [L, *-*, l_=\small{$L_{j,j}$}] (8,0)
to [L, l_=\small{$L_{j+1,j+1}$}] (12,0) % _ change direciton of letter L

(4,4)
to [L, l=\small{$M_{j,j}$}] (4,2)
to [C, l=\small{$C^{'}_{j}$}] (4,0)

(8,4)
to [L, l=\small{$M_{j+1,j+1}$}] (8,2)
to [C, l=\small{$C^{'}_{j+1}$}] (8,0)


{(2,1.5) node {\small{\color{red}{$I_{j-1}$}}}
(6,1.5) node {\small{\color{red}{$I_{j}$}}}
(10,1.5) node {\small{\color{red}{$I_{j+1}$}}}
};

\draw[thin,red, <-, >=triangle 45] (2,1) arc (-90:90:1);

\draw[thin,red, <-, >=triangle 45] (6,1) arc (-90:90:1);

\draw[thin,red, <-, >=triangle 45] (10,1) arc (-90:90:1);

\end{circuitikz}

\end{document}
Last edited by beningermany on Sun Aug 26, 2018 10:52 pm, edited 1 time in total.

beningermany
Posts: 10
Joined: Tue Aug 21, 2018 5:55 pm

Postby beningermany » Sat Aug 25, 2018 8:39 am

Hi, Stefan,
I still have no idea how to make the lines without the method of node.
I can only change the following command

\node [ fill=white, inner sep=1pt] at (capacitor-top\i) {};
\node [circle, draw, fill=white, inner sep=1pt] at (capacitor-bottom\i) {};

which will show ellipse with dashed lines (not precisely). How could you make the lines without the node or coordinate method?

Have a nice weekend!
Attachments
highpass.png
highpass.png (30.94 KiB) Viewed 436 times

User avatar
Stefan Kottwitz
Site Admin
Posts: 9192
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sat Aug 25, 2018 3:21 pm

beningermany wrote:How could you make the lines without the node or coordinate method?


I defined the nodes so one can refer to them (draw lines between) or place symbols (such as capacitors). Here it is without nodes and without coordinates:

  1. \documentclass[border=10pt]{standalone}
  2. \usepackage{tikz}
  3. \usetikzlibrary{positioning}
  4. \begin{document}
  5. \begin{tikzpicture}[font=\scriptsize]
  6. \def\height{5}
  7. \def\width{3}
  8. \draw (0, 0) ellipse (\width cm and 1 cm);
  9. \draw (0,-\height ) ellipse (\width cm and 1 cm);
  10. \foreach \i in { 1,...,5 }
  11. \draw (45*\i+138:\width cm and 1cm) -- ++(0,-\height);
  12. \foreach \i in { 6,...,8 }
  13. \draw [dashed] (45*\i+138:\width cm and 1cm) -- ++(0,-\height);
  14. \end{tikzpicture}
  15. \end{document}


Stefan
Site admin

beningermany
Posts: 10
Joined: Tue Aug 21, 2018 5:55 pm

Postby beningermany » Sat Aug 25, 2018 4:41 pm

Hi Stefan,
thank you very much for spending time on my question.
I do not understand the following command:
\draw (45*\i+138:\width cm and 1cm) -- ++(0,-\height);
for instance, i=1,
then \draw (183:3cm and 1cm) -- ++ (0,-height)

The definition of polar system: ( :r dim), why inside of the command, there are 3 cm and 1 cm , respectively?
I know there is difference, after deleting the 1cm. Could you please explain it to me?


The crucial problem is how to add the symbol of capacitors in the eclipses and on the legs ( lines connecting two eclipse.)

Cheers
Ben

beningermany
Posts: 10
Joined: Tue Aug 21, 2018 5:55 pm

Postby beningermany » Sun Aug 26, 2018 10:38 pm

finally, I know " \draw (45*\i+138:\width cm and 1cm) -- ++(0,-\height); "
for ellipse, therefore, angle: radius1,radius 2

User avatar
Stefan Kottwitz
Site Admin
Posts: 9192
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sun Aug 26, 2018 10:44 pm

I can take a look at drawing capacitors, perhaps tomorrow, as it gets night here. If not using the circuitikz library, it could be a simple double line (white filled to overprint the ellipse).

Stefan
Site admin

beningermany
Posts: 10
Joined: Tue Aug 21, 2018 5:55 pm

Postby beningermany » Sun Aug 26, 2018 10:58 pm

Hi Stefan,
There will be no confusing any longer. We do not need any circuitikz for the sketch.
The only figures I want to draw are a and b, as showed in the first attachment.
Namely, simple double line will be sufficient to illustrate the capacitor.
There is no need to use the package of circuitikz to draw the capacitor.
Thanks a lot.
good night.

Ben

User avatar
Stefan Kottwitz
Site Admin
Posts: 9192
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Tue Aug 28, 2018 5:19 pm

Hi Ben,

here is a try. The capacitor is a node style, filled white (overwriting ellipse or edges), with lines drawn at both sides.

  1. \documentclass[border=10pt]{standalone}
  2. \usepackage{tikz}
  3. \usetikzlibrary{positioning}
  4. \makeatletter
  5. \begin{document}
  6. \begin{tikzpicture}[
  7. capacitor/.style = {
  8. fill = white,
  9. inner sep = 0pt,
  10. minimum width = 1.2mm,
  11. minimum height = 5mm,
  12. append after command =
  13. { (\tikzlastnode.south west) edge[black] (\tikzlastnode.north west)
  14. (\tikzlastnode.south east) edge[black] (\tikzlastnode.north east)} }
  15. ]
  16. \def\height{5}
  17. \def\width{3}
  18. \draw (0, 0) ellipse (\width cm and 1 cm);
  19. \draw (0,-\height ) ellipse (\width cm and 1 cm);
  20. \foreach \i in { 1,...,8 } {
  21. \coordinate (top\i) at (45*\i+138:\width cm and 1cm);
  22. \coordinate [below = \height cm of top\i] (bottom\i);
  23. \coordinate (capacitor-top\i) at (45*\i+158.5:\width cm and 1cm);
  24. \coordinate [below = \height cm of capacitor-top\i]
  25. (capacitor-bottom\i);
  26. }
  27. \foreach \i in { 1,...,5 }
  28. \draw (top\i) -- (bottom\i);
  29. \foreach \i in { 6,...,8 }
  30. \draw [dashed] (top\i) -- (bottom\i);
  31. \foreach \i in { 1,...,8 } {
  32. \node [capacitor]
  33. at (capacitor-top\i) {};
  34. \node [capacitor]
  35. at (capacitor-bottom\i) {};
  36. }
  37. \end{tikzpicture}
  38. \end{document}


capacitor.png
capacitor.png (13.56 KiB) Viewed 320 times


Stefan
Site admin


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 11 guests