xpos = analogRead(4);
ypos = analogRead(5);
Serial.println(atan2(xpos, ypos));
The first problem is that analogRead only returns values from 0 to 1023 so atan2 will think that your values are always in the positive quadrant.
Second you have the x and y values the wrong way round for atan2 as I pointed out right at the beginning of message #3.
If your joystick is in its centre position, it probably will give x,y readings of around 511,511 or 512,512. In that case you can convert them to the range -512 to 511 by just subtracting 512 from x and y.
xpos = analogRead(4) - 512;
ypos = analogRead(5) - 512;
Serial.println(atan2(ypos, xpos));
Pete