function purge(gd) {
    gd = Lib.getGraphDiv(gd);

    var fullLayout = gd._fullLayout || {};
    var fullData = gd._fullData || [];

    // remove gl contexts
    Plots.cleanPlot([], {}, fullData, fullLayout);

    // purge properties
    Plots.purge(gd);

    // purge event emitter methods
    Events.purge(gd);

    // remove plot container
    if(fullLayout._container) fullLayout._container.remove();

    // in contrast to _doPlots.purge which does NOT clear _context!
    delete gd._context;

    return gd;
}
Purge a graph container div back to its initial pre-_doPlot state

@param {string id or DOM element} gd
     the id or DOM element of the graph container div