Define a 'ggplot2' object as "sourceable", which means that it knows how to keep track of its source code (parameter must be a 'ggplot2' object)
sourceable(x)