Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Could someone help me produce this diagram in TikZ? enter image description here

This is the code I have right now.

\begin{tikzpicture}
\draw (3.5, 3.5) circle (130 pt);

\draw[blue, very thick] (-1, 3.5) parabola (5.5, 1.5);
\draw[blue, very thick] (-2.5, 3.5) -- (-1, 3.5);
\draw (5.5, 1.5) node [anchor=north] {$(x, y)=O$};
\draw [black, very thick] (5.5, 1.5) circle (2 pt); 
\draw [black, very thick] (-1, 1.5) circle (2 pt);
\draw (-1, 1.5) node [anchor= north east] {$B$};
\draw [red, very thick] (-1, 1.5) -- (5.5, 1.5);
\draw [red, very thick] (-1, 1.5) -- (-1, 3.5);
\draw [very thick] (-1, 1.8) -- (-0.7, 1.8);
\draw [very thick] (-0.7, 1.8) -- (-0.7, 1.5);
\draw [very thick] (-1, 1.8) -- (-1, 1.5);
\draw [very thick] (-1, 1.5) -- (-0.7, 1.5);
\draw (-1, 1.5) -- (-1, -6) node[near end, left] {$R-y$};
\draw (-1, -6) -- (5.5, 1.5) node[near start, below] {$R$};
\draw [very thick] (-1, -6) circle (2 pt);
\draw (-1, -6) node [anchor=north east] {$E$};
\foreach \x in {1,...,6}
\foreach \y in {1,...,6}
{
\draw (\x,\y) +(-.5,-.5) rectangle ++(.5,.5);

}
\end{tikzpicture}
share|improve this question
6  
here is an example which shows it in a 3d view: tug.org/PSTricks/main.cgi?file=Examples/Physics/… –  Herbert May 10 '13 at 7:08
    
If you are new to TikZ I would recommend the great manual and also the examples on texample.net before starting with something complicated. –  Alexander May 10 '13 at 12:24

1 Answer 1

up vote 13 down vote accepted

I tried to comment a lot, please don't hesitate to ask if anything is unclear:

Code

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

\begin{tikzpicture}
    % replace nested foreach by grid; also draw it earlier so it does not paint over the red line
    \draw (1,1) grid[shift={(-0.5,-0.5)}] (7,7);

    %  put a coordinate in the end for reference
    \draw [very thick] (5.5, 1.5) circle (2 pt) coordinate (myOrigin); 

    % also a coordinate here
    \draw [very thick] (-1, 1.5) circle (2 pt) coordinate[label=180:B] (myB);
    \draw [very thick] (-1, -6) circle (2 pt) coordinate[label=270:E] (myE);

    % try not to mix units (e.g. cm/pt); use arcs to construct the curved part
    \draw (-5.3,4) -- (-1.3,4) arc (270:360:0.3) arc (170:-170:4.5) arc (0:90:0.3) -- ++ (-4,0);

    % draw red line with the "first vertical, then horizontal" notation; put another coordinate
    \draw [red, very thick]  (-1, 3.5) coordinate (myA) |- (myOrigin);

    % you can draw the whole blue line in one command, use coordinate
    \draw[blue, very thick] (myA) -- (-1.5,3.5) (-1, 3.5) parabola (myOrigin);

    % imho looks better outside; stealth is an arrow tip
    \draw[stealth-,shorten <=2mm] (myOrigin) -- ++(-30:2cm) node[below right] {$(x, y)=O$};

    % use rectangle operation instead of 4 draw commands
    \draw[very thick] (-1,1.5) rectangle (-0.7,1.8);

    % use coordinates and "pos" key
    \draw (myE) -- (myB) node[left,pos=0.5] {$R-y$};
    \draw (myE) -- (myOrigin) node[below right,pos=0.5] {$R$};

    % draw the ?electron source?
    \foreach \x in {0,1,2}
    {   \fill[gray] (-1.5-\x/5,3.85) rectangle (-1.6-\x/5,3.2);
    }
    \draw (-2.1,3.2) rectangle (-1.5,3.85);

    % draw the ?heater?
    \draw[thick] (-2.3,3.55) arc (0:135:0.3) -- ++ (225:0.8);
    \draw[thick] (-2.3,3.55) arc (0:-135:0.3) -- ++ (-225:0.8);

    % gray filling
    \fill[gray] (-5.3,3.1) rectangle (-3.3,3.95);

    %decription arrows
    \draw[stealth-,shorten <=1mm] (myA) -- ++ (-0.5,2.5) node[above] {A};
\end{tikzpicture}

\end{document}

Output

enter image description here

share|improve this answer
1  
Thanks a ton! Should I cite your work in the paper in which this diagram will go? –  Reuben Stern May 10 '13 at 19:04
1  
You're welcome! No need citing me, you did most of the work, I merely tweaked and made afew additions. –  Tom Bombadil May 11 '13 at 1:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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