I am able to a horizontal sine wave using the below code.

\draw[domain = 0:4] plot [smooth] (\x,{0.4 * sin(\x * pi/2 r)});

How to draw an inclined sine wave using TikZ? Something similar to the following image: enter image description here

1 Answer 1

\documentclass[tikz, border=1cm]{standalone}
\draw (0,0) -- (2,0) cos (3,1) sin (4,2) -- (6,2);

Curve with sine function

  • @ hpekristiansen, I am not able understand combinationation of cos and sin that produces the desired output. Can you please explain?
    – Aim
    Dec 14, 2021 at 13:40
  • Try to delete cos (so that this part is not draw) - then you can see what part of the curve it draws. Basically cos draws a quarter of a cosine wave stretched and moved, so that the endpoints match the given coordinates. -and the same for sin. Dec 14, 2021 at 14:24
  • @Aim You could also learn from the doc for sin and cos, which is in pgfmanual v3.1.9a, sec. 14.10 "The Sine and Cosine Operation". Dec 14, 2021 at 18:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .