Let AB be the line segment between the axes and let P (a, b) be its mid-point.

Let the coordinates of A and B be (0, y) and (x, 0) respectively.
Since P (a, b) is the mid-point of AB,
\(\left(\frac{0+x}{2},\frac{y+0}{2}\right)=(a,b)\)
\(⇒\left(\frac{x}{2},\frac{y}{2}\right)=(a,b)\)
\(⇒\frac{x}{2}=a\space and \space \frac{y}{2}=b\)
\(∴x=2a\) and \(y=2b\)
Thus, the respective coordinates of A and B are (0, 2b) and (2a, 0).
The equation of the line passing through points (0, 2b) and (2a, 0) is
\((y-2b)=\frac{\left(0-2b\right)}{\left(2a-0\right)}(x-0)\)
\(y-2b=\frac{-2b}{2a}(x)\)
\(a(y-2b)=-bx\)
\(i.e,bx+ay=2ab\)
On dividing both sides by \(ab\), we obtain
\(\frac{bx}{ab}+\frac{ay}{ab}=\frac{2ab}{ab}\)
\(⇒\frac{x}{a}+\frac{y}{b}=2\)
Thus, the equation of the line is \(\frac{x}{a}+\frac{y}{b}=2\)