3

I'm looking for a code drawing the below picture with TikZ if it is possible:

I just need the graph in the middle, i.e. there is no need to also include the text and/or equations. Simply the plot together with the axes would be more than fine.

From the suggestions of the comments I found this piece of code online that I copied but somehow it refuses to work: The source that I stole it from was a PDF and when I pasted it into a TeX-editor there were a lot of unnecesary blank space and other stuff. I suspect that's why it didn't work.

% Codice di Spike
\documentclass[a4paper ,11 pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[y ={(0.866 cm,-0.5 cm)} , x ={(-0.866 cm ,-0.5 cm )},z ={(0 cm ,1 cm )}]
\coordinate(O) at (0 , 0 , 0);
\draw [-latex ](O) -- +(2 , 0 , 0) node [ left ]{$ x $};
\draw [-latex ](O) -- +(0 , 7 , 0) node [ right ]{$ y $};
\draw [-latex ](O) -- +(0 , 0 , 2) node [ above ]{$ z $};
 % onde e vettori che indicano l? intensita ? dei campi
\draw [thick,color=teal,variable=\x,samples at ={0 ,0.1 ,... ,6.3}] 
    plot ({ - sin (2* \x r )},\x ,0) node [ anchor = north ]{$ \vec { E }$};
\foreach \x in {0.25 , 0.5 ,... ,6}
    \draw [ color =teal , - latex ] (0 , \x ,0) -- ({ - sin (2* \x r )} , \x ,0);
    \draw [thick , color = purple , variable =\x , samples at ={0 ,0.1 ,... ,6.3} ]
    plot (0 , \x ,{ - sin (2* \x r )}) node [ anchor = west ]{$ \vec { H }$};
\foreach \x in {0.25 , 0.5 ,... ,6}
     \draw [color = purple , - latex] (0 , \x ,0) -- (0 , \x ,{ - sin (2* \x r )});
    % lambda - " lunghezza d? onda " dell ? onda
    \draw [help lines] (0 ,2.35 ,1.4) -- (0 ,2.35 ,1.6);
    \draw [help lines] (0 ,5.49 ,1.4) -- (0 ,5.49 ,1.6);
    \draw [help lines] (0 ,2.35 ,1.5) -- (0 ,5.49 ,1.5)
    node [pos =0.5 , fill =white , text = black ]{$ \lambda $};
\end{tikzpicture}
\end{document}

enter image description here

Stefan Pinnow
  • 29,535
  • 4
    Downvoted: you've been around long enough to know that this site's purpose is not to do your work for you. Please, show what you've tried so far or describe a specific problem you're trying to solve. – Paul Gessler Feb 23 '15 at 13:02
  • 2
    You can use Mark Wibrow's amazing answer to get started. If you get stuck, feel free to ask a more concrete question. – Jake Feb 23 '15 at 13:05
  • 1
    See also: http://www.texample.net/tikz/examples/polarizing-microscope/ – Paul Gessler Feb 23 '15 at 13:05
  • 1
    You may want to have a look to http://www.guitex.org/home/images/doc/GuideGuIT/introingtikz.pdf, chapter 4. – Claudio Fiandrino Feb 23 '15 at 13:11
  • 1
    Relax guys. No need to get upset. Some people treat SE sites like some holy book type shit. damn. – Physics_maths Feb 23 '15 at 13:13
  • Thanks for the links though, I guess I'll have to take it from there. – Physics_maths Feb 23 '15 at 13:15
  • @LoveLearning: you should better thank spike ;) – Claudio Fiandrino Feb 23 '15 at 13:28
  • 4
    Actually, people are saying precisely that the site should not be regarded as a 'give me the answer' black box. – cfr Feb 23 '15 at 13:29
  • 3
    @LoveLearning: Thanks for adding the code to the question. However, "somehow it refuses to work" is not very helpful. Do you get an error message? If so, what error message? Or is the output not what you expected? If so, how does it differ from your expectation? – Jake Feb 23 '15 at 13:35
  • Please do NOT edit questions to include answers. It is really confusing. Since you've also modified the code, I don't know whether to roll-back or not and have just flagged for moderator attention instead. – cfr Aug 26 '16 at 21:17

1 Answers1

22

With TikZ

\documentclass{article}
\usepackage{tikz,bm}
\usepackage[raggedrightboxes]{ragged2e}
\begin{document}
\begin{center}
  \begin{tikzpicture}[x={(-10:1cm)},y={(90:1cm)},z={(210:1cm)}]
    % Axes
    \draw (-1,0,0) node[above] {$x$} -- (5,0,0);
    \draw (0,0,0) -- (0,2,0) node[above] {$y$};
    \draw (0,0,0) -- (0,0,2) node[left] {$z$};
    % Propagation
    \draw[->,ultra thick] (5,0,0) -- node[above] {$c$} (6,0,0);
    % Waves
    \draw[thick] plot[domain=0:4.5,samples=200] (\x,{cos(deg(pi*\x))},0);
    \draw[gray,thick] plot[domain=0:4.5,samples=200] (\x,0,{cos(deg(pi*\x))});
    % Arrows
    \foreach \x in {0.1,0.3,...,4.4} {
      \draw[->,help lines] (\x,0,0) -- (\x,{cos(deg(pi*\x))},0);
      \draw[->,help lines] (\x,0,0) -- (\x,0,{cos(deg(pi*\x))});
    }
    % Labels
    \node[above right] at (0,1,0) {$\bm{E}$};
    \node[below] at (0,0,1) {$\bm{B}$};
  \end{tikzpicture}

  \begin{minipage}{.5\linewidth}
    \[
      c = \frac{E}{B}
    \]
    \begin{tabular}{r@{${}={}$}p{.8\linewidth}}
      $E$ & electric field amplitude \\
      $B$ & magnetic field amplitude (instantaneous values) \\
      $c$ & speed of light ($3\times10^8\mathrm{m/s}$) \\
    \end{tabular}
  \end{minipage}%
  \begin{minipage}{.5\linewidth}
    \[
      c = \frac{1}{\sqrt{\mu_0 \varepsilon_0}}
    \]
    \begin{tabular}{r@{${}={}$}p{.8\linewidth}}
      $\mu_0$ & magnetic permeability in a vacuum, $\mu_0 = 1.3\times10^{-6}\,\mathrm{N/A^2}$ \\
      $\varepsilon_0$ & electric permeability in a vacuum, $\varepsilon_0 = 8.9\times10^{-12}\,\mathrm{C^2/N m^2}$ \\
    \end{tabular}
  \end{minipage}
\end{center}
\end{document}

enter image description here

Henri Menke
  • 109,596