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

  • 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 '17 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. – Artemij Keidan Jan 13 '17 at 0:38
13

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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