I thought a bit about it, and actually you can calculate the axis with just one value.
In the code it says:
accXangle = acos(accXval/R)*RAD_TO_DEG-90;
accYangle = acos(accYval/R)*RAD_TO_DEG-90;
Instead you could write:
accXangle = asin(accXval)*RAD_TO_DEG;
accYangle = asin(accYval)*RAD_TO_DEG;
Then you should get an angle very close to the first one!! It is not as precise as the first one, but that kind of precision is only important if you are building a balancing robot or something like that.
The resolution will also only be 180 degrees.
That should fix your problem