The massless Dirac fermions and the ease to introduce spatial and magnetic confinement in graphene provide us unprecedented opportunity to explore confined relativistic matter in this condensed-matter system. Here we report the interplay between the confinement induced by external electric fields and magnetic fields of the massless Dirac fermions in graphene. When the magnetic length lB is larger than the characteristic length of the confined electric potential lV, the spatial confinement dominates and a relatively small critical magnetic field splits the spatial-confinement-induced atomic-like shell states by switching on a pi Berry phase of the quasiparticles. When the lB becomes smaller than the lV, the transition from spatial confinement to magnetic confinement occurs and the atomic-like shell states condense into Landau levels (LLs) of the Fock-Darwin states in graphene. Our experiment demonstrates that the spatial confinement dramatically changes the energy spacing between the LLs and generates large electron-hole asymmetry of the energy spacing between the LLs. These results shed light on puzzling observations in previous experiments, which hitherto remained unaddressed.