I think the direction of the magnetic field taken is itself wrong. In the given figure the direction of magnetic field of earth is taken to be B and H and Z are its respective horizontal and vertical components. Now, according to this direction of the magnetic field. The North Pole of the needle of the magnetic compass will actually point towards the geographic South Pole which I have not heard of happening (though I could be unaware of such occurrence). I want to verify if this figure is actually correct. This figure is from my high school textbook. According to the convention given in textbook north magnetic pole is near the geographic North Pole and south magnetic pole is near the south geographic pole. The field lines emerge from the south magnetic pole and enter the north magnetic pole to form closed loops.
The poles of the magnet Earth are as in the figure included in this link: https://www.wtamu.edu/~cbaird/sq/2013/11/15/why-does-a-magnetic-compass-point-to-the-geographic-north-pole/ The South of the Earth magnet is near the geografic North and vice-versa. By convention, the end of the compass pointing (approximatelly) towards the geografic North was labeled "North". So, being attracted by the South of another magnet (and repelled by the North) it must point towards a real magnetic South pole. Unfortunatelly, you can see many web pages labeling the pole of the magnet Earth near the geografic North as "magnetic North". This is either uisng a different convention than the one in physics or is just ignorance of physics, expecially when they show the actual magnet, modelling Earth, with the North pole in the Arctic zone. Too bad that the figure is from a physics textbook. Maybe you should look for a different book. Look here, slide no 6, for the image in a decent book: https://web.njit.edu/~tyson/P122-ECE_Lecture8_Ch27.pdf