具有高级绘图功能的多个绘图,尤其是 plot.rqs() [英] Multiple plots with high-level plotting functions, especially plot.rqs()

查看:37
本文介绍了具有高级绘图功能的多个绘图,尤其是 plot.rqs()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用一个居中的标题并排绘制两个回归摘要.每个回归摘要由 plot.rqs() 生成,相当于一组 9 个图.

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 plots.

我已经尝试过使用 par(mfrow=c(1,2)),但正如我从 Paul Murrel (2006) 的书中了解到的,像 plot 这样的高级函数.rqs()pairs() 保存绘制前的图形状态,完成后恢复图形状态,以便抢先调用par()layout() 帮不了我.plot.rqs() 也没有面板"功能.

I've tried using par(mfrow=c(1,2)) already, but as I learnt from Paul Murrel's (2006) book, high-level functions like plot.rqs() or pairs() save the graphics state before drawing and then restore the graphics state once completed, so that pre-emptive calls to par() or layout() can't help me. plot.rqs() doesn't have a 'panel' function either.

看来实现结果的唯一方法是修改plot.rqs()函数以获得一个新函数,比如modified.plot.rqs(),然后运行

It seems that the only way to achieve the result is to modify the plot.rqs() function to get a new function, say modified.plot.rqs(), and then run

par(mfrow=c(1,2))
modified.plot.rqs(summary(fit1))
modified.plot.rqs(summary(fit2))
par(mfrow=c(1,1))

从那里我也许可以使用 layout() 来计算如何为图像添加整体标题.有谁知道如何创建一个可以以这种方式使用的 modified.plot.rqs() 函数?

From there I might be able to work out how to add an overall title to the image using layout(). Does anyone know how to create a modified.plot.rqs() function that could be used in this way?

谢谢

推荐答案

首先我们生成一个示例对象 fm .然后我们复制 plot.rqs 并在副本上使用 trace 在顶部插入 par <-list 有效地取消了对 的任何使用par 函数内.然后我们对 plot.summary.rqs 做同样的事情.最后我们用我们自己的 par 测试一下:

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)

添加了plot.summary.rqs.

这篇关于具有高级绘图功能的多个绘图,尤其是 plot.rqs()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆