1

I want to use tikz or pgf plots to sketch the following figure.

enter image description here

I don't know how I can do this. I am new to tikz any help is much appreciated.

3

2 Answers 2

4

enter image description here

%% Compile and read me!
\documentclass[a4paper,12pt]{article}
\usepackage{tikz}

\begin{document}


\tikzset{every picture/.style={line width=0.75pt}} %set default line width to 0.75pt        

\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1]
%uncomment if require: \path (0,465); %set diagram left start at 0, and has height of 465

%Straight Lines [id:da44099480189728735] 
\draw    (300,19.6) -- (300,393.6) ;
\draw [shift={(300,16.6)}, rotate = 90] [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.08]  [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle    ;
%Straight Lines [id:da8824771822192676] 
\draw    (407.93,205.1) -- (502,205.1) ;
\draw [shift={(505,205.1)}, rotate = 180] [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.08]  [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle    ;
%Straight Lines [id:da24280879301545077] 
\draw    (92,205.1) -- (300,205.1) ;
%Shape: Circle [id:dp11281010206938324] 
\draw   (146,205.1) .. controls (146,118.12) and (216.52,47.6) .. (303.5,47.6) .. controls (390.48,47.6) and (461,118.12) .. (461,205.1) .. controls (461,292.08) and (390.48,362.6) .. (303.5,362.6) .. controls (216.52,362.6) and (146,292.08) .. (146,205.1) -- cycle ;
%Straight Lines [id:da261614095586969] 
\draw  [dash pattern={on 0.84pt off 2.51pt}]  (300,205.1) -- (407.93,205.1) ;
%Straight Lines [id:da3729646825074229] 
\draw  [dash pattern={on 0.84pt off 2.51pt}]  (407.93,205.1) -- (407.93,87.93) ;
%Shape: Circle [id:dp2255990803694814] 
\draw  [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ,fill opacity=1 ] (403.97,88.9) .. controls (403.97,86.71) and (405.74,84.93) .. (407.93,84.93) .. controls (410.12,84.93) and (411.9,86.71) .. (411.9,88.9) .. controls (411.9,91.09) and (410.12,92.87) .. (407.93,92.87) .. controls (405.74,92.87) and (403.97,91.09) .. (403.97,88.9) -- cycle ;
%Straight Lines [id:da14689165256365078] 
\draw    (303.5,205.1) -- (407.93,88.9) ;
%Shape: Arc [id:dp27880451250057914] 
\draw  [draw opacity=0][line width=0.75]  (344.18,167.51) .. controls (349.23,175.91) and (353.14,189.82) .. (353.9,203.67) -- (339.77,195.58) -- cycle ; \draw  [line width=0.75]  (344.18,167.51) .. controls (349.23,175.91) and (353.14,189.82) .. (353.9,203.67) ;  
%Straight Lines [id:da6066277021045829] 
\draw    (355.47,228.93) -- (405.87,279.33) -- (468.93,279.33) ;
%Shape: Brace [id:dp3449182976418521] 
\draw   (304.47,207.93) .. controls (304.47,212.6) and (306.8,214.93) .. (311.47,214.93) -- (345.7,214.93) .. controls (352.37,214.93) and (355.7,217.26) .. (355.7,221.93) .. controls (355.7,217.26) and (359.03,214.93) .. (365.7,214.93)(362.7,214.93) -- (399.93,214.93) .. controls (404.6,214.93) and (406.93,212.6) .. (406.93,207.93) ;
%Shape: Brace [id:dp27574411654123265] 
\draw   (404.93,87.33) .. controls (401.44,84.24) and (398.15,84.44) .. (395.05,87.93) -- (354.77,133.34) .. controls (350.35,138.33) and (346.39,139.27) .. (342.9,136.18) .. controls (346.39,139.27) and (345.93,143.31) .. (341.5,148.3)(343.49,146.06) -- (302.34,192.45) .. controls (299.25,195.94) and (299.45,199.24) .. (302.94,202.34) ;
%Shape: Brace [id:dp27059078621693455] 
\draw   (413.93,204.33) .. controls (418.6,204.33) and (420.93,202) .. (420.93,197.33) -- (420.93,157.83) .. controls (420.93,151.16) and (423.26,147.83) .. (427.93,147.83) .. controls (423.26,147.83) and (420.93,144.5) .. (420.93,137.83)(420.93,140.83) -- (420.93,98.33) .. controls (420.93,93.66) and (418.6,91.33) .. (413.93,91.33) ;
\draw   (353.6,174.07) .. controls (348.84,171.22) and (345.22,167.87) .. (342.73,163.98) .. controls (344.08,168.39) and (344.31,173.32) .. (343.39,178.79) ;

% Text Node
\draw (285.47,183.33) node [anchor=north west][inner sep=0.75pt]  [font=\large]  {$0$};
% Text Node
\draw (275,208.5) node [anchor=north west][inner sep=0.75pt]  [font=\large]  {$O$};
% Text Node
\draw (409.93,208.5) node [anchor=north west][inner sep=0.75pt]  [font=\large]  {$Q$};
% Text Node
\draw (369.47,131.33) node [anchor=north west][inner sep=0.75pt]  [font=\large]  {$1$};
% Text Node
\draw (328.47,183.33) node [anchor=north west][inner sep=0.75pt]    {$\theta $};
% Text Node
\draw (471.47,267.33) node [anchor=north west][inner sep=0.75pt]  [font=\large]  {$x=\cos \theta $};
% Text Node
\draw (408.47,59.33) node [anchor=north west][inner sep=0.75pt]  [font=\large]  {$P( x,y)$};
% Text Node
\draw (432.47,137.33) node [anchor=north west][inner sep=0.75pt]  [font=\large]  {$y=\sin \theta $};
% Text Node
\draw (500.47,212.33) node [anchor=north west][inner sep=0.75pt]  [font=\large]  {$x$};
% Text Node
\draw (278.47,25.33) node [anchor=north west][inner sep=0.75pt]  [font=\large]  {$y$};


\end{tikzpicture}
\end{document}
2
  • 5
    I assume that you did it with mathlab, Sebastiano. All those extremely precise numbers make me think that it's automatized. I'm not the downvoter here, but for example, the arrowed angle theta is pretty weird on the picture you provided. This fairly simple picture could be drawn with much less commands. No harm intended, obviously, because you're a very stron helper here ;)
    – SebGlav
    Jan 21 at 14:19
  • 2
    Please keep comments on topic: I have cleaned up here
    – Joseph Wright
    Jan 22 at 12:33
7

Libraries:

The keys x and y specify the length of the unit 1 in the xyz coordinate system.

Instead of that angled line to the x label I've just put it directly under the brace.

I purposefully did not make the angle line thick and shadowed. That doesn't look nice in my opinion.

The specific start and end points of the brace could be shifted a bit orthogonally to the line but that isn't that trivial.

Code

\documentclass[tikz]{standalone}
%\usepackage{tikz}
\usetikzlibrary{arrows.meta, bending, angles, decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[
  x=4cm, y=4cm, >=Triangle,
  bracy/.style={decoration={brace, amplitude=2mm}},
  dec/.style={decorate, draw, solid}
]
\coordinate[label=below left:$O$]         (O) at (0,0)
 coordinate[label=above right:{$P(x,y)$}] (P) at (60:1)
 coordinate[label=below right:$Q$]        (Q) at (P|-O)
 foreach \xy in {x, y} {foreach \pm in {+, -} {
   coordinate (\xy\pm) at (xyz cs: \xy=\pm 1.1)}};

\draw (O) circle [radius=1];
\fill (P) circle [radius=2pt];

\draw[densely dotted] (P) -- (Q) [postaction={dec, bracy}]
  node[midway, fill=white, right=2mm] {$y=\sin \phi$};
\draw[densely dotted] (Q) -- (O) [postaction={dec, bracy}]
  node[midway, below=2mm] {$x=\cos \phi$};
\draw[decorate, bracy] (O) -- (P) node[midway, above left=1mm] {$1$};

\draw[->] (x-) -- (O) -- (P)
          (Q)  -- (x+) node[right] {$x$};
\draw[->] (y-) -- (y+) node[above] {$y$};

\pic[draw, blue, ->, pic text=$\phi$, angle radius=7mm] {angle=Q--O--P};
\end{tikzpicture}
\end{document}

Output

enter image description here

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