Liquid configurations generated by Metropolis Monte Carlo simulations are used in time-dependent density functional theory calculations of the spectral line shifts of atomic impurities in rare-gas environment. Consistent results are obtained for the Xe 5p→6s excitation in Ar environment in all thermodynamic conditions considered, with densities varying from 0.15 to 1.40 g/cm3, thus ranging from the low to the high-density situation, including supercritical condition. The results reproduce very well the dependence of the spectral shift with the density, giving also good quantitative results for the low, intermediate and high-density cases.