Photoacoustic microscopy (PAM) is becoming a vital tool for various biomedical studies, including functional and molecular imaging of cancer. However, due to the use of a focused ultrasonic transducer for photoacoustic detection, the image quality of conventional PAM degrades rapidly away from the ultrasonic focal zone. To improve the image quality of PAM for out-of-focus regions, we have developed compressed sensing based virtual-detector photoacoustic microscopy (CS-PAM). Through phantom and in vivo experiments, it has been demonstrated that CS-PAM can effectively extend the depth of focus of PAM, and thus may greatly expand its potential biomedical applications.