Compositionally graded ferroelectrics (cgFEs), which possess a spatial variation in material composition, exhibit anomalous or even unprecedented properties. Despite several breakthroughs having been achieved in experiments, there surprisingly is a lack of an effective simulation approach for cgFEs, thereby greatly hindering a deep understanding about underlying mechanisms hidden behind the observed phenomena. In this study, an improved phase field model is proposed for a cgFE made of PbZr(1−x)TixO3 based on the Ginzburg–Landau theory. The improved approach enables us to capture several key phenomena occurring in the cgFE PbZr0.8Ti0.2O3 ⇔ PbZr0.2Ti0.8O3 thin film that are observed from experiments, such as the formation of needle-like domains with curved domain walls, ferroelastic switching under an electric field, and the voltage offset of the hysteresis loop. Results obtained from the improved approach indicate that the high elastic energy near the needle-tip of an a-domain gives rise to a deflection of the domain wall from the regular a/c domain wall, while the high concentration of the depolarization field shrinks a part of the a-domain near the needle-tip and terminates the a-domain within the cgFE thin film. These facilitate the stabilization of needle-like domains with curved domain walls in the cgFE thin film. Furthermore, the flexoelectricity is proven to play an important role in the voltage offset of the hysteresis loop. On the other hand, the ferroelectric switching process in the cgFE thin film exhibits a vastly different response in comparison to that in homogeneous ferroelectric thin films, including local switching initiation and formation and annihilation of vortex–antivortex pairs during the switching. The present study, therefore, provides an incisive approach for investigations on cgFEs, which may bring new understanding and unique insights into these complex materials, as well as novel potential applications.