2016-01-20 37 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