Just create it in the same cell. Change
To Legend(f[1,1],...
But then you need to figure the how to position it properly and that I don’t know myself ![]()
Alternatively, you might be looking for the function axislegend which does that for you. However you already posted the image from its documentation so I assume you feel you need to use Legend?