[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)