That colored line is not the heart rate. It’s the walking speed.
Never ruin a good story with facts

I suppose it depends on the app, I don’t know the one in the image but the ones I use does color the path with the heart rate.

When hiking, the redder spots are the harder parts and the whole line matches the graph with heartrate over time.

I know when I had a Garmin watch it changed what was defaulted to on the map depending on the activity.