# Can someone help me with this? (special graph)

**URL:** <https://discourse.processing.org/t/can-someone-help-me-with-this-special-graph/27838>\
**Category:** Coding Questions\
**Created:** [February 15, 2021, 2:53pm UTC](https://discourse.processing.org/t/can-someone-help-me-with-this-special-graph/27838 "2021-02-15T14:53:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cocopuffs](https://avatars.discourse-cdn.com/v4/letter/c/6a8cbe/32.png) [@cocopuffs](https://discourse.processing.org/u/cocopuffs)\
**Post date:** [February 15, 2021, 2:53pm UTC](https://discourse.processing.org/t/can-someone-help-me-with-this-special-graph/27838/1 "2021-02-15T14:53:55Z")

</div>

So I basically have to create the exact sketch/animation as depicted in the gif.  
I attached a gif of exactly how it needs to look and animate (you may need to refresh page in a few minutes because I think the gif stops moving after a few minutes.) So, I’m having a hard time mainly figuring out how to make some of the curves different sizes (similar to the gif). In my code that I have now, all the curves are at the same y axis level and not similar to the gif. I’m not just looking for the answer, I genuinely want to understand and learn how it’s done. So I’m looking to how I can get the finishing results! Someone please help me!

![movingWave](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/ae4a5485753c8095f7d6989835343913c5c029f8.gif)

The code that I have so far is:

int numPts = 300;  
size(400,400);  
background(0);  
noStroke();  
fill(255);  
for(float i = 1; i \<= numPts; i++) {  
float y = sin(i/15);  
ellipse(i \* width/numPts, height/2 + 50 \* y, 10, 10);  
}

---

<div class="post-metadata">

**Author:** ![NumericPrime](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/numericprime/32/16318_2.png) [@NumericPrime](https://discourse.processing.org/u/NumericPrime)\
**Post date:** [February 15, 2021, 4:10pm UTC](https://discourse.processing.org/t/can-someone-help-me-with-this-special-graph/27838/2 "2021-02-15T16:10:38Z")

</div>

try using

```auto
int numPts = 300;
void setup(){
size(400,400);
noStroke();
fill(255);
}
void draw(){
for(float i = 1; i <= numPts; i++) {
float y=sin((i+frameCount)/15);
ellipse(i * width/numPts, height/2 + 50 * y, 10, 10);
}

```

---

<div class="post-metadata">

**Author:** ![micycle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micycle/32/201_2.png) [@micycle](https://discourse.processing.org/u/micycle)\
**Post date:** [February 15, 2021, 5:04pm UTC](https://discourse.processing.org/t/can-someone-help-me-with-this-special-graph/27838/3 "2021-02-15T17:04:33Z")

</div>

A curve like that is made from summing multiple waves of differing frequencies.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a106a5a391c65368723372036ad149c0e9696835.png)

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [February 15, 2021, 8:34pm UTC](https://discourse.processing.org/t/can-someone-help-me-with-this-special-graph/27838/4 "2021-02-15T20:34:18Z")

</div>

do you calculate the average of the sin-waves to get the new one or is there a different way?

---

<div class="post-metadata">

**Author:** ![micycle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micycle/32/201_2.png) [@micycle](https://discourse.processing.org/u/micycle)\
**Post date:** [February 15, 2021, 10:35pm UTC](https://discourse.processing.org/t/can-someone-help-me-with-this-special-graph/27838/5 "2021-02-15T22:35:06Z")

</div>

Simply summing them all up will give you the shape.

To squeeze it back between -1…1 you’d divide by the number of waves (an average).

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [February 16, 2021, 7:46am UTC](https://discourse.processing.org/t/can-someone-help-me-with-this-special-graph/27838/6 "2021-02-16T07:46:33Z")

</div>

thank you!  
I made this with it!

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/f68632307fac762b11a8d168647950b582971cf5.png)
