Refactoring

Some refactoring of the gain plotting in nbplot.py