# TODO: Add comment
# 
# Author: E.Korsching  2024
###############################################################################



#### legend on its own plot area

plot.star.weight.leg <- function(colors, meaning, title="", cex=1, y.intersp=2){
	# legend for plot.star.weight()
	# vectors: colors: R color names,  meaning: text per color
	cl <- length(colors)
	ml <- length(meaning)
	if(cl!=ml){ stop("colors and meaning needs to be of same length") }
	plot(0,0, type="n", axes=F, xlab="", ylab="", xlim=c(0,1), ylim=c(0,1))
	par(mar=c(0.1,0.1,0.1,0.1))
	legend("topleft",
		inset=0.05,
		legend=meaning,
		col=colors,
		bty="n",
		pch=19,
		cex=cex,
		pt.cex=cex*4,
		adj=c(0, 0.5),
		text.col="black",
		text.font=NULL,
		title=title,
		x.intersp=2,
		y.intersp=y.intersp)
	par(mar=c(5,4,4,2))
	return()
}


#plot.star.weight.leg(colors=c("cornsilk","deepskyblue","sienna1","gray","white"),
#	meaning=c(
#	"Reference at the center",
#	"Synergistic action",
#	"Antagonistic action",
#	"Gray if there is a zero Pearson correlation value",
#	"Length of connector lines 2.5-1.5 antagonistic, 1.5-0.5 synergistic"),
#	cex=1)



