3

I am MSc Student and new to LaTeX I wanna draw a diagram from last two days but don't know how to draw this I tries a lot. I am trying to draw like this as attached picture.

Here is an other code I tried but this is to small diagram.

\documentclass[a4paper, oneside]{standalone}
\usepackage{tikz}







\begin{document}
\begin{pgfpicture}
    \pgfsetcornersarced{\pgfpoint{5pt}{5pt}}
    \pgfpathmoveto{\pgfpointpolar{340}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{10}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{20}{0.5cm}}
    \pgfpathlineto{\pgfpointpolar{30}{0.4cm}}
%   \pgfpathlineto{\pgfpointpolar{40}{0.3cm}}
%   \pgfpathlineto{\pgfpointpolar{50}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{60}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{70}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{80}{1cm}}
    \pgfpathlineto{\pgfpointpolar{90}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{100}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{110}{0.5cm}}  
%   \pgfpathlineto{\pgfpointpolar{120}{0.5cm}}
    \pgfpathlineto{\pgfpointpolar{130}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{140}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{150}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{160}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{170}{0.5cm}}
    \pgfpathlineto{\pgfpointpolar{180}{0.3cm}}
%   \pgfpathlineto{\pgfpointpolar{290}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{200}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{210}{0.3cm}}
%   \pgfpathlineto{\pgfpointpolar{220}{0.3cm}}
%   \pgfpathlineto{\pgfpointpolar{230}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{240}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{250}{0.5cm}}
    \pgfpathlineto{\pgfpointpolar{260}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{270}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{280}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{290}{0.5cm}}
    \pgfpathlineto{\pgfpointpolar{300}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{310}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{320}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{330}{0.5cm}}
%   \pgfpathlineto{\pgfpointpolar{340}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{350}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{360}{1cm}}



%   \pgfpathlineto{\pgfpointpolar{115}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{135}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{145}{1cm}}




%   \pgfpathlineto{\pgfpointpolar{135}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{155}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{165}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{265}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{300}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{315}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{325}{1cm}}
%   \pgfpathlineto{\pgfpointpolar{360}{1cm}}
    \pgfpathclose
    \pgfusepath{stroke}



    \begin{tikzpicture}[ thin]
    \draw[->] (-3.3,-0.3) -- (-2.1,-0.1);
%   \draw (-3.1,-2.2) -- (-2.1,-1.7);
    \draw (-3.2,-0.5) -- (-2.1,-0.3);
    \draw (-3.1,-0.7) -- (-2.1,-0.5);
    %\begin{scope}[thin]
    %\draw (-4,0.-3) -- (0,-1);
    %\draw (2,0) -- (2,1);
    %\end{scope}
    \draw (3,0) -- (3,1);
    \end{tikzpicture}





\end{pgfpicture}






%\begin{tikzpicture}[ultra thick]
%\draw (0,0) -- (0,1);
%\begin{scope}[thin]
%\draw (1,0) -- (1,1);
%\draw (2,0) -- (2,1);
%\end{scope}
%\draw (3,0) -- (3,1);
%\end{tikzpicture}

\end{document}





\documentclass{article}

\usepackage{tikz}

\begin{document}
\begin{figure}[h!]
  \begin{center}
    \begin{tikzpicture}
      \draw [thick] (-1,2) % Draws a line
      to [out=10,in=190] (1,4)
     % to [out=10,in=190] (1,3)
      to [out=10,in=90] (6,0)

      to [out=-90,in=-30] (-1,2);    
    \end{tikzpicture}
    \caption{fig 2.}
  \end{center}
\end{figure}
\end{document}
2

I have only drawn the second drawing.

enter image description here

\documentclass{standalone}
\usepackage{tikz}
\tikzset {b/.code = {\pgfsetadditionalshadetransform{ \pgftransformshift{\pgfpoint{0 bp } { 0 bp }  }  \pgftransformrotate{0 }  \pgftransformscale{2 }  }}}
\pgfdeclarehorizontalshading{a}{150bp}{rgb(0bp)=(1,1,1);
rgb(37.5bp)=(1,1,1);
rgb(45.427829197474885bp)=(0.88,0.88,0.88);
rgb(50bp)=(0.95,0.95,0.95);
rgb(62.5bp)=(0.96,0.96,0.96);
rgb(100bp)=(0.96,0.96,0.96)}
\tikzset{every picture/.style={line width=0.75pt}}
\begin{document}

\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1]
\draw    (180,111) -- (112,172) ;
\draw [shift={(112,172)}, rotate = 318.26] [color=black]   (0,0) .. controls (3.31,-0.3) and (6.95,-1.4) .. (10.93,-3.3)(0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

\draw    (180,111) -- (180,12) ;
\draw [shift={(180,12.32)}, rotate = 450] [color=black]   (0,0) .. controls (3.31,-0.3) and (6.95,-1.4) .. (10.93,-3.29)(0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

\draw    (180,111.32) -- (315,112) ;
\draw [shift={(315,112)}, rotate = 180.42] [color=black]   (0,0) .. controls (3.31,-0.3) and (6.95,-1.4) .. (10.93,-3.29)(0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

\path  [shading=a,b] (208,68) .. controls (228,58) and (318,48) .. (298,68) .. controls (278,88) and (278,98) .. (298,128) .. controls (318,158) and (228,158) .. (208,128) .. controls (188,98) and (188,78) .. (208,68) ;  
 \draw   (208,68) .. controls (228,58) and (318,48) .. (298,68) .. controls (278,88) and (278,98) .. (298,128) .. controls (318,158) and (228,158) .. (208,128) .. controls (188,98) and (188,78) .. (208,68) ; 
\draw    (243.5,76.47) -- (289,32.47) ;
\draw [shift={(289,32.47)}, rotate = 495.96] [color=black]   (0,0) .. controls (3.31,-0.3) and (6.95,-1.4) .. (10.93,-3.29)(0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
\draw  [dash pattern={on 0.85pt off 2.50pt}]  (204,113) -- (244,77) ;
\draw    (163,150) -- (200,117);
\draw    (181,171) -- (217.6,138) ;
\draw    (171,161) -- (208,128) ;
\draw  [dash pattern={on 0.84pt off 2.51pt}]  (224,133.2) -- (264,96) ;
\draw    (263.5,96.47) -- (309,52.47) ;
\draw [shift={(309,53)}, rotate = 496] [color=black]   (0,0) .. controls (3.31,-0.3) and (6.95,-1.4) .. (10.93,-3.29)(0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

\draw  [dash pattern={on 0.84pt off 2.51pt}]  (214.6,123.19) -- (254.5,86.47) ;
\draw    (254.5,86) -- (300,42) ;
\draw [shift={(300,43)}, rotate = 496] [color=black]   (0,0) .. controls (3.31,-0.3) and (6.95,-1.4) .. (10.93,-3.29)(0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
\draw    (199,74) -- (200,6.46) ;
\draw [shift={(200,6.46)}, rotate = 450.85] [color=black]   (0,0) .. controls (3.31,-0.3) and (6.95,-1.4) .. (11,-3.29)(0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
\draw    (199,74) -- (233,47) ;
\draw [shift={(233,47)}, rotate = 500] [color=black ]   (0,0) .. controls (3.31,-0.3) and (6.95,-1.4) .. (10.93,-3.29)(0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;
\draw (135,170) node [scale=0.8]  {$x$};
\draw (331,116) node [scale=0.8]  {$y$};
\draw (166,28) node [scale=0.8]  {$z$};
\draw (306,150) node [scale=0.8]  {$C$};
\draw (315,37) node [color=black ,opacity=0.7]  {$I$};
\draw (210,29) node [scale=0.8]  {$\mathbf{B}$};
\draw (246,43) node [scale=0.8]  {d$\overline{r}$};


\end{tikzpicture}

\end{document}
  • Done! :-) I followed your advice. Thank you so much for the positive vote. – Sebastiano Apr 18 '18 at 21:21
6

All these \pgfpathlineto etc. coordinates work in principle, but are only really relevant if you want to invent new decorations and the like. However, if you want to make some 3D-like pictures, I'd recommend tikz-3dplot. Here are two quick examples, hopefully simple and self-explanatory enough that you can adjust them to your needs.

enter image description here

\documentclass[tikz,border=3.14pt]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows.meta}
\begin{document}
\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}[scale=2.0, line cap=round, line join=round, >=latex,tdplot_main_coords]
\draw[->] (0,0,0) -- (3,0,0)node[below]{$x$};
\draw[->] (0,0,0) -- (0,3,0)node[below]{$y$};
\draw[->] (0,0,0) -- (0,0,3)node[left]{$z$};
\draw [fill] (0,0,0) circle (0.5pt) node[below]{0};
\draw[thick] (0,0,1) to[out=80,in=165] (1,1,2) coordinate(X) to[out=-15,in=150] (1,2.5,1);
\draw[->] (0,0,0) -- (X) node[midway,right]{$\vec r$};
\draw[->] (X) --++(0.1,0.4,0.) node[above] {d$\vec r$};
\end{tikzpicture}
\begin{tikzpicture}[scale=2.0, line cap=round, line join=round, >=Triangle,tdplot_main_coords]
\draw[-latex] (0,0,0) -- (0,0,3)node[left]{$B$};
\foreach \X in {1,2,3}
\draw[very thick,->] (1,{0.5*\X},0) -- ++(0,1,3);
\begin{scope}
\clip plot [smooth cycle] coordinates {(0,0,1) (1,2,2)  (1,2.5,1)
(0.1,2,0.2)};
\fill[white] plot [smooth cycle] coordinates {(0,0,1) (0,1,1)  (1,2.5,0.8)
(0.1,2,0)};
\end{scope}
\draw[thick] plot [smooth cycle] coordinates {(0,0,1) (1,2,2)  (1,2.5,1)
(0.1,2,0.2)};
\node at (1,2.6,0.5) {$C$};
\end{tikzpicture}
\end{document}
  • @FaizaNiaz You're welcome. If you want to improve(?) the second picture, just replace \fill[white] plot [smooth cycle] coordinates {(0,0,1) (0,1,1) (1,2.5,0.8) (0.1,2,0)}; by \fill[white,opacity=0.8] plot [smooth cycle] coordinates {(0,0,1) (0,1,1) (1,2.5,0.8) (0.1,2,0)};. (I've designed the picture for that, but then forgot to put the opacity directive. – user121799 Apr 18 '18 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.