The interaction between phonons and high-energy excitations of electronic origin in cuprates and their role in the superconducting mechanisms is still controversial. Here we use coherent vibrational time-domain spectroscopy together with density functional and dynamical mean-field theory calculations to establish a direct link between the c-axis phonon modes and the in-plane electronic charge excitations in optimally doped YBa2Cu3O7. The nonequilibrium Raman tensor is measured by means of the broadband “coherent-phonon” response in pump-probe experiments and is qualitatively described by our model using density functional theory in the frozen-phonon approximation plus single-band dynamical mean-field theory to account for the electronic correlations. The major outcome of our experimental and theoretical study is to establish the link between out-of-plane copper ion displacements and the in-plane electronic correlations, and to estimate at a few unit cells the correlation length of the associated phonon mode. The approach introduced here could help in revealing the complex interplay between fluctuations of different nature and spatial correlation in several strongly correlated materials.