因此,我一直试图将半透明色带放入时间序列图。我已经使用ggplot对条形图进行了相同的操作,但由于时间序列的数据大小,我无法将其键入到数据框中(通过Microsoft Excel逗号分隔工作),因此非常有效,但是值文件加载到R中)。因此,希望能够将其转换为数据帧,或者在其上绘制半透明块。
下面的代码和相关的错误消息。
plot(Nitrate_Interp~RiverWensum$Rdates, type="l", xlab="Time", ylab="Nitrate (mg N L)", las=1,
col="black")
rect((RiverWensum$Rdates)-1,lower_yNr,(RiverWensum$Rdates)+1,upper_yNr, density=30, col="#FF000080",
border="red")
#defining the colour
mycol <- rgb(225,0,0,max=225,alpha=125,names="red.5")
mycol
red.5 = "#FF000080"
#error given when script run:
Error in rgb(255, 0, 0, max = 220, alpha = 125, names = "red50") :
colour intensity 1.15909, not in [0,1]
谢谢旅馆
rgb()
函数的设置为maxColorValue
,而不是max
,您应该将其设置为所选的最大值(尽管它似乎可以工作,而且似乎不是问题)。查看错误:
Error in rgb(255, 0, 0, max = 220...
...您的最大值也小于红色值,因此它将不起作用。 255/220> 1