How do I convert a 3-axis quaternion to a 1-axis x-y axis plane?

The Mahony AHRS and similar algorithms are called filters because they combine the contributions of several orientation sensors to produce one "average" orientation, which can be represented by three angles or one quaternion.

Gyros can be calibrated upon program start as long as the sensor is not moving or being reoriented. Simply collect a couple of hundred measurements, sum and average to calculate the X, Y and Z offsets to be subtracted. See the calibration code in the above Github link for the details.

The MPU-6050 has not been manufactured for several years, and what you get on the market today are most likely Chinese clones (not guaranteed to work as expected), rejects or outright fakes.

For a commercial product you will need to design for and buy a newer 6DOF or 9DOF sensor.