簡體   English   中英

如何將透明矩形添加到R boxplot(plot)?

[英]how to add a transparent rectangle to a R boxplot (plot)?

我有一個簡單的箱形圖用於我的數據使用R ..

boxplot (Error~Code, DataFrame1, xlim = c(0, 27),
     xlab="set Code",ylab="Error", boxwex=0.75, cex.axis=0.3)

我想在2個定義的y值之間繪制一個透明的矩形:( - 50)和(100)!

我在上一個腳本之后嘗試使用函數rect,如下所示:

  rect(0,-50,27,100, col= 'tomato2', density=10)

但這並沒有給我一個透明的均勻彩色矩形!

有人可以幫助我嗎? 到目前為止,我差不多花了2個多小時沒有成功。

提前謝謝了!

density會導致交叉影線,這不是你想要的。 你想要的是alpha混合。

嘗試

# arguments to rgb(r,g,b and alpha) should be between 0 and 1.0
# this will make transparent blue
rect(x0,y0,x1,y1, col= rgb(0,0,1.0,alpha=0.5))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM