code for the Gosia paper figure