Graphics, Figures & TablestikZ | Points on the Sine Curve

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

tikZ | Points on the Sine Curve

Post by ghostanime2001 »

How can I include a circle on the sine curve without knowing the exact coordinates of the y-value? For example I want to put a circle mark on the sine curve at the point 10pi/13. Is there a way to do that with the tikzpicture environment?

For example with this code:

Code: Select all

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw (0,0) sin (1,1) cos (2,0) sin (3,-1) cos (4,0) sin (5,1) cos (6,0);
\draw (0,0) sin (1.4,1) cos (2.4,0) sin (3.4,-1) cos (4.4,0) sin (5.4,1) cos (6.4,0);
\draw (-0.2,0) -- (6.4,0);
\draw (0,1.1) -- (0,-1.1);
\end{tikzpicture}
\end{document}
Last edited by ghostanime2001 on Thu Nov 24, 2011 7:32 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

tikZ | Points on the Sine Curve

Post by localghost »

It's easier if you exploit the capabilites of the pgf/tikZ package instead of piecing together your plot curves.

Code: Select all

\documentclass{minimal}
\usepackage{tikz}

\begin{document}
  \begin{tikzpicture}
    \draw (-0.5,0) -- (11,0) (0,-1.5) -- (0,1.5);
    \draw plot[domain=0:9.4248,smooth] (\x,{sin(\x r)});
    \draw plot[domain=0:10.4719,smooth] (\x,{sin(0.9*\x r)});
    \fill[red] (4.1888,{sin(4.1888 r)}) circle (2pt);
  \end{tikzpicture}
\end{document}
Details in the package manual.


Thorsten
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Re: tikZ | Points on the Sine Curve

Post by ghostanime2001 »

can pst-func or pst-plot do this even better?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

tikZ | Points on the Sine Curve

Post by localghost »

ghostanime2001 wrote:can pst-func or pst-plot do this even better?
I don't know. But the corresponding package manuals should tell you that. This thread is about pgf/tikZ. And if we have a solution, you know what to do then. For a solution with PSTricks you can always open a new topic. But don't change the main subject here.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

tikZ | Points on the Sine Curve

Post by cgnieder »

In my opinion it would be even easier to use multiples of pi to draw the plot:

Code: Select all

\documentclass{minimal}
\usepackage{tikz}

\begin{document}
  \begin{tikzpicture}
    \draw (-0.5,0) -- (11,0) (0,-1.5) -- (0,1.5);
    \draw plot[domain=0:3*pi,smooth] (\x,{sin(\x r)});
    \draw plot[domain=0:3*pi/.9,smooth] (\x,{sin(0.9*\x r)});
    \fill[red] (10*pi/13,{sin(10*pi/13 r)}) circle (2pt);
    \fill[red] (13*pi/10,{sin(13*pi/10 r)}) circle (2pt);
  \end{tikzpicture}
\end{document}
Best
site moderator & package author
Post Reply