referencegraph <- function(x,y,indicator){
#color
transparency=.5
green1=rgb(34,139,34,transparency*255,maxColorValue = 255)
green2=rgb(45,201,55,transparency*255,maxColorValue = 255)
yellow1=rgb(231,180,22,transparency*255,maxColorValue = 255)
orange1=rgb(219,123,43,transparency*255,maxColorValue = 255)
red1=rgb(204,50,50,transparency*255,maxColorValue = 255)
clear=rgb(0,0,0,transparency*255,maxColorValue = 255*4)
coords=data.frame(x,y)
plot(-666, xlab=indicator,
ylab="",
xaxs="i",yaxs="i",
xlim=c(x[1],x[length(x)]),
ylim=c(y[1],y[length(y)]),par(las=1))
if(length(x)==4){
colorscale<-c(clear,red1,yellow1,green1)
}else{
if(length(x)==5){
colorscale<-c(clear,red1,orange1,yellow1,green1)
}else{
if(length(x)==6){
colorscale<-c(clear,red1,orange1,yellow1,green2,green1)
}else{
print("you have have to define your own color scale. For example, if you have 7 points, colorscale <-c(clear,red1,orange1,...) ")}
}}
{for(i in length(x):1){
colorpicker=colorscale[i]
rect(xleft = x[1],ytop = y[i],xright = x[i],ybottom = y[1], col="white",border = clear)
rect(xleft = x[1],ytop = y[i],xright = x[i],ybottom = y[1], col=colorpicker,border = colorpicker)}
{for(i in length(x):1){
segments(x[i],y[i],x[i+1],y[i+1],lty=3,lwd=1.6)
}}}
par(new=TRUE)
plot(coords$x,coords$y,
xlab=indicator,
ylab="Attainment score (%)",
xaxs="i",yaxs="i",
xlim=c(x[1],x[length(x)]),
ylim=c(y[1],y[length(y)]),
pch=20)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.