[script][figure] Fix bug with histo legends and add comments/doc in the code

4 jobs for fixlegends in 13 minutes and 25 seconds (queued for 5 seconds)
Status Job ID Name Coverage
  Build
passed #140565
docker
build_linux_27

00:13:20

86.0%
passed #140566
docker
build_linux_36

00:13:15

86.0%
passed #140567
macosx
build_macosx_27

00:09:25

86.0%
passed #140568
macosx
build_macosx_36

00:11:07

86.0%