  We have carried out a systematic study of the crystal electric field
excitations in the family of cubic pyrochlores Er$_2B_2$O$_7$, with $B=$~Ti,
Ge, Pt, and Sn, using neutron spectroscopy. All members of this family are
magnetic insulators based on 4$f^{11}$ Er$^{3+}$ and non-magnetic $B^{4+}$. At
sufficiently low temperatures, long-range antiferromagnetic order is observed
in each of these Er$_2B_2$O$_7$ pyrochlores. Our inelastic neutron scattering
measurements probe the transitions from the ground state doublet to excited
crystal electric field states belonging to the $J=15/2$ Hund's rules manifold.
This allows us to quantitatively determine the energy eigenvalues and
eigenfunctions of these $(2J+1)=16$ states across the Er$_2B_2$O$_7$ series.
The different ionic sizes associated with different non-magnetic $B^{4+}$
cations correspond to positive or negative chemical pressure, depending on the
relative contraction or expansion of the crystal lattice, which gives rise to
slightly different local environments at the Er$^{3+}$ site. Our results show
that the $g$-tensor components, which characterize the anisotropy of the ground
state doublet eigenfunctions, are XY-like for all four members of the
Er$_2B_2$O$_7$ series. However, the XY anisotropy is much stronger for
Er$_2$Pt$_2$O$_7$ and Er$_2$Sn$_2$O$_7$ ($\frac{g_{\perp}}{g_z} > 25$), than
for Er$_2$Ge$_2$O$_7$ and Er$_2$Ti$_2$O$_7$ ($\frac{g_{\perp}}{g_z} < 4$). The
variation in the nature of the XY-anisotropy in these systems correlates
strongly with their ground states, as Er$_2$Ge$_2$O$_7$ and Er$_2$Ti$_2$O$_7$
order into $\Gamma_5$ magnetic structures, while Er$_2$Pt$_2$O$_7$ and
Er$_2$Sn$_2$O$_7$ order in the $\Gamma_7$ Palmer-Chalker structure.
