5

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).

2
  • 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
    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. Jan 13, 2017 at 0:38

1 Answer 1

14

You mean something like the following?

% used PGFPlots v1.14
    \RequirePackage{luatex85}
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{
        % increases compilation speed when using LuaLaTeX
        compat=1.12,
    }
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            hide axis,
        ]
            \addplot [
                only marks,
                domain=0:25,
                samples=2001,
                mark size=0.75,
            ] (
                {0.75*sin(deg(x)) + x},
                {rand}
            );
        \end{axis}
    \end{tikzpicture}
\end{document}

image showing the result of above code

5
  • Nice! Out of curiosity, is there a reason you picked 2001 samples (instead of 2000)?
    – Jake
    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 ;) Jan 12, 2017 at 20:42
  • Thank you so much, this is exactly what I meant! I would never find it out myself... 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 ✓). Jan 12, 2017 at 21:24
  • @StefanPinnow I am new to this site, did not realize that I had to vote the answer. 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 .