There is almost zero magnetic field near the middle of the bar magnet. So, if a compass is placed near the middle of a bar magnet, the effect of earth's magnetic field will be stronger on the compass. So, the needle of the compass will rest in the north-south direction.