Not a bioinformatics question but an R programming one. See this SO post.
The trick is to plot the red line over an image, i.e. use the heatmap as background image to the plot. This can be done with the R package ggplot2 and the rasterGrob() function.