move plot export code to a common module