For a presentation on the human hearing I need to create a sketchy diagram representing the behaviour of the air particles when they are passed through by a pressure wave. Something like this: enter image description here

Can I make such a diagram with PGFPlots? It allows to draw a randomly distributed marks across a rectangular, but I haven't found out how to change the density of the dots as a function of sin(x).

  • 1
    Welcome to TeX.SE. It would help us a lot, if you could present an MWE of what you have tried already by yourself. In your case, there are a lot of nice TikZ and PFG-examples on the net around. Have you found anything usable there?
    – Jan
    Commented Jan 12, 2017 at 17:02
  • @Jan I did my best to find some ready made template or example, including the one provided here. However I was not able to modify it according to my needs. Commented Jan 13, 2017 at 0:38

1 Answer 1


You mean something like the following?

% used PGFPlots v1.14
        % increases compilation speed when using LuaLaTeX
            hide axis,
            \addplot [
                only marks,
                mark size=0.75,
            ] (
                {0.75*sin(deg(x)) + x},

image showing the result of above code

  • Nice! Out of curiosity, is there a reason you picked 2001 samples (instead of 2000)?
    – Jake
    Commented Jan 12, 2017 at 20:37
  • 3
    @Jake, the "nice" belongs to you. Because this is just a very simplified version of your awesome answer tex.stackexchange.com/a/145972/95441. No, this is just habit I would say. Because "normally", when you want to have "round" numbers, you need let's say 51 samples. From that it went up to 101, then to 1001 and finally ending at 2001 ;) Commented Jan 12, 2017 at 20:42
  • Thank you so much, this is exactly what I meant! I would never find it out myself... Commented Jan 12, 2017 at 21:05
  • 1
    @ArtemijKeidan, you are welcome. For your information: If this answer suits your needs you could -- besides upvoting the answer (with the upward pointing arrow to the left of it) -- also accept it (by clicking on the checkmark ✓). Commented Jan 12, 2017 at 21:24
  • @StefanPinnow I am new to this site, did not realize that I had to vote the answer. Commented Jan 13, 2017 at 0:29

You must log in to answer this question.

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