Plot a graph through processing

Hello,

I’ve having a bit of a problem with this exercise. I’m supposed to plot a the graph 300=(x*x)/200;
To get there x is supposed to be added 0.1 at each time and the graph should stop at y=300.
Through my current code I can code up the whole graph as indivial points but it’s supposed to show the whole graph from 0<x<245 as red circles. The background should be black.

Anyone that has any ideas what i might be doing wrong, would really be appreciated and thanks in advance. The code is:

float x =0;
float y =0;
void setup(){  
size(400,400);
background(0);


}

void draw(){

  x=x+0.1;
  y=(x*x)/200;
fill(255,0,0);
   ellipse(x,400-y,5,5);


  
}

1 Like

The problem is that, by default, the ellipses have a black outline and as you are plotting all your points really close together, these outlines are overlapping the previous points so they appear black and blend in with the background.
Put noStroke() in draw to get rid of the outlines.

2 Likes

exactly,

float step = 0.1;

void setup() {  
  size(400, 400);
  fill(255,0,0);
  stroke(255,0,0);
}

void draw() {
  background(0);
  for ( float x = 0; x < 245; x += step ) ellipse(x, 400-(x*x)/200, 5, 5);
}