Multiple plots with high-level plotting functions, especially plot.rqs()

前端 未结 2 1274
借酒劲吻你
借酒劲吻你 2021-01-20 02:09

I am trying to plot two regression summaries side-by-side with one centered title. Each regression summary is generated by plot.rqs() and amounts to a set of 9

2条回答
  •  伪装坚强ぢ
    2021-01-20 02:48

    First we generate an example object, fm . Then we copy plot.rqs and use trace on the copy to insert par <- list at top effectively nullifying any use of par within the function. Then we do the same with plot.summary.rqs. Finally we test it out with our own par:

    library(quantreg)
    example(plot.rqs) # fm to use in example
    
    # plot.rqs
    plot.rqs <- quantreg::plot.rqs
    trace("plot.rqs", quote(par <- list), print = FALSE)
    
    # plot.summary.rqs
    plot.summary.rqs <- quantreg::plot.summary.rqs
    trace("plot.summary.rqs", quote(par <- list), print = FALSE)
    
    # test it out
    op <- par(mfrow = c(2, 2))
    
    plot(summary(fm))
    plot(fm)
    title("My Plots", outer = TRUE, line = -1)
    
    par(op)
    

    EDIT: added plot.summary.rqs.

提交回复
热议问题