2016-01-20 60 views
2

我遇到了一个问题,我的图总是在浅灰色的背景上,在LaTeX中看起来很糟糕。我已经使用par(bg=NA)par(bg="white")这是每个人都建议,但是,从字面上什么都不做尝试...当使用qcc(质量控制图)时,R中的灰色背景阴谋

下面的代码:

# install.packages('qcc') 
library(qcc) 
nonconforming <- c(3, 4, 6, 5, 2, 8, 9, 4, 2, 6, 4, 8, 0, 7, 20, 6, 1, 5, 7) 
samplesize <- rep(50, 19) 
control <- qcc(nonconforming, type = "p", samplesize, plot = "FALSE") 
warn.limits <- limits.p(control$center, control$std.dev, control$sizes, 2) 
par(mar = c(5, 3, 1, 3), bg = "blue") 
plot(control, restore.par = FALSE, title = "P Chart for Medical Insurance Claims", 
    xlab = "Day", ylab = "Proportion Defective") 
abline(h = warn.limits, lty = 3, col = "blue") 
v2 <- c("LWL", "UWL") # the labels for warn.limits 
mtext(side = 4, text = v2, at = warn.limits, col = "blue", las = 2) 
+1

请尽量提供代码,自给自足用于复制(这里它缺少数据) – HubertL

+0

完成,谢谢你的回复。 – CanofDrink

回答

2

退房?qcc.options() - 具体而言,bg.margin选项。下面将改变你的阴谋有lightgreen背景(注:可能不是LaTeX的一个不错的选择,但它说明了这一点):

library(qcc) 
nonconforming <- c(3, 4, 6, 5, 2, 8, 9, 4, 2, 6, 4, 8, 0, 7, 20, 6, 1, 5, 7) 
samplesize <- rep(50, 19) 

old <- qcc.options() # save the original options 
qcc.options(bg.margin = "lightgreen") 
par(mar = c(5, 3, 1, 3)) 
control <- qcc(nonconforming, type = "p", samplesize, plot = "FALSE") 
warn.limits <- limits.p(control$center, control$std.dev, control$sizes, 2) 
plot(control, restore.par = FALSE, title = "P Chart for Medical Insurance Claims", 
    xlab = "Day", ylab = "Proportion Defective") 
abline(h = warn.limits, lty = 3, col = "blue") 
v2 <- c("LWL", "UWL") # the labels for warn.limits 
mtext(side = 4, text = v2, at = warn.limits, col = "blue", las = 2) 
qcc.options(old) # reset the old options 

Plot

+0

啊辉煌,没想到这将是一个qcc选项。感谢编辑,我会尽量在下次更好的格式。 – CanofDrink

+1

@ HarrisonO'Neill没问题。带我去找了一下。有时候,查看源代码是最简单的 - 我输入'plot.qcc'来查找它正在做什么,并看到一行:'par(bg = qcc.options(“bg.margin”)...'和这导致我在文档中查找'qcc.options' – JasonAizkalns

+0

任何想法如何去隐藏CL和LCL?我必须生成一个范围图,我们通常不会绘制中心线或控制下限 – CanofDrink