5

So I have this code here,

   \begin{tikzpicture}

    % Draw the axes
    \draw [->,black] (-1.5,0) -- (3,0) ;
    \draw [->,black] (0,-1.5) -- (0,3) ;

    % Draw the line
    \draw[-,black](0,0)--(3,2);

    % Draw the circle
    \path [draw,green] (+1.5,0) circle (1.5);
    \path [draw,cyan] (0,1.5) circle (1.5);

    % Intersection of circle and line
    \draw[dashed,cyan](0,0.93)--(1.38,0.93);
    \draw[dashed,cyan](1.38,0.93)--(1.38,0);
    \draw[dashed,green](0,1.38)--(2.1,1.38);
    \draw[dashed,green](2.1,0)--(2.1,1.38);
  %  \node[] at (-0.25,1.78){$y$};

     \node[] at (-0.25,0.93){$y_3$};
     \node[] at (1.38,-0.25){$x_3$};


\coordinate (a) at (0,0);
      \coordinate (b) at (1.38,0.93);
    \draw[decorate,decoration={brace,amplitude=5pt,raise=1pt,mirror},yshift=0pt] (a) -- (b) node [midway,yshift=-10pt, xshift = 10pt]{$|z_3|$};
     \node[] at (-0.25,1.38){$y_2$};
     \node[] at (2.1,-0.25){$x_2$};  

   % \node[] at (2.9,-0.25) {$x$};

    % Draw the angle
    \draw [red] (0,0.3) arc (90:33:0.3);
    \draw[red] (0,0.4)arc(90:33:0.4);
    \node[] at (60:.6)  {$\alpha$};

    % Done
\end{tikzpicture}

, which gives me the following image:

enter image description here

However, what I would like to do is make brace/markers on the segments shown in the picture. (It is clear where I have hand-drawn them in).

How can I modify the above to be able to do so?

6

For the braces, you can use the brace decoration. You can use the intersections library to calculate the intersection points between the line and the circles; in this way, you don't have to manually calculate coordinates; I also reduced the font size to \scriptsize:

\documentclass{article}
\usepackage{tikz}% just for the example
\usetikzlibrary{decorations.pathreplacing,intersections}
\begin{document}

 \begin{tikzpicture}[every node/.append style={font=\scriptsize}]

    % Draw the axes
    \draw [->,black] (-1.5,0) -- (3,0) ;
    \draw [->,black] (0,-1.5) -- (0,3) ;

    % Draw the line
    \path[name path=line,draw,-] (0,0) -- (3,2);

    % Draw the circle
    \path [name path=greencircle,draw,green] (+1.5,0) circle (1.5);
    \path [name path=bluecircle,draw,cyan] (0,1.5) circle (1.5);

% find intersections of line and circles
\path[name intersections={of=line and bluecircle, by={a,b}}];
\path[name intersections={of=line and greencircle, by={c,d}}];

% lines from axes to intersection points
    \draw[dashed,cyan] (0,0|-b) -- (b);
    \draw[dashed,cyan] (b|-0,0) -- (b);
    \draw[dashed,green] (0,0|-c) -- (c);
    \draw[dashed,green] (c|-0,0) -- (c);;
  %  \node[] at (-0.25,1.78){$y$};

     \node[left] at (0,0|-b) {$y_3$};
     \node[below] at (b|-0,0) {$x_3$};

     \node[left] at (0,0|-c) {$y_2$};
     \node[below] at (c|-0,0) {$x_2$};  

   \coordinate (O) at (0,0);
% draw braces
    \draw[decorate,decoration={brace,amplitude=5pt,raise=0.5pt,mirror},yshift=0pt] (O) -- (b) node [midway,yshift=-9pt, xshift =6pt]{$|z_3|$};
    \draw[decorate,decoration={brace,amplitude=5pt,raise=0.5pt},yshift=0pt] (O) -- (c) node [midway,yshift=11pt, xshift =-5pt]{$|z_2|$};

   % \node[] at (2.9,-0.25) {$x$};

    % Draw the angle
    \draw [red] (0,0.3) arc (90:33:0.3);
    \draw[red] (0,0.4)arc(90:33:0.4);
    \node[] at (60:.6)  {$\alpha$};

    % Done
\end{tikzpicture}
\end{document}

enter image description here

  • Thanks so much! Some questions: 1) How do I move the curvy part of the brace to somewhere arbitrary? (Right now it is in the middle. What if I want to make it like, 1/3 of the way?) 2) I know that I can use font=\tiny for the font of the text, however is there something smaller than tiny? Thanks a million! :) – Spacey May 15 '13 at 13:23
  • @Mohammad 1) you can use the aspect key to give a fraction of the total length where the "middle part" of the brace will be, an example: decoration={brace,aspect=.33,amplitude=5pt,raise=0.5pt} 2) If your font allows it, you can use smaller sizes: \fontsize{3}{4}\selectfont – Gonzalo Medina May 15 '13 at 13:31
  • If you want braces or brackets perpendicular instead of parallel to the line, is the best way to just place two nodes around a point on the line and connect a brace to each? – bright-star Mar 8 '14 at 19:50
  • 1
    @TrevorAlexander that would depend on what you actually are trying to achieve. Please feel free to open a new question. – Gonzalo Medina Mar 8 '14 at 23:04
  • I figured it out with help from this question. A simple way is just: \node (thisbracket) at (3,0) {]}; – bright-star Mar 8 '14 at 23:08

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.