What is happening?
A bar magnet is approximated as a magnetic dipole. The field direction is calculated from the dipole vector equation and points from the north pole around to the south pole outside the magnet. Compass arrows align with the local field direction.