The correct solution is not to set the height and width, but to set autosize
:
layout = Layout(;autosize = true,
xaxis = attr(title="x", range=[0.0, L]),
yaxis = attr(title = "F", range=[-1.0, 1.0]))
Then the figure is responsive during the simulation as well as after.