Could be ...

legend("topright",legend=c("Histogram","Kernel Density
Estimate"),lty=c(NA,1), lwd=c(NA,2), pch = c(15, NA), col = c("lightblue", "black"), merge=TRUE,inset=.01,cex=.8,adj=0)

A.

John Kerpel wrote:
Hi folks!  I'm trying to get a histogram legend to give me a filled box and
a line.  The problem is I keep getting both filled boxes and a line.  How
can I get rid of the second box from the code below?



x<-rnorm(1000,mean=0,sd=1)

hist(x, breaks = 50, main="Histogram of x",freq=FALSE,

xlab=" x", ylab="Density",col="lightblue", border="black")

x_dens<-density(x,kernel="gaussian")

points(x_dens,type="l",lwd=3)

legend("topright",legend=c("Histogram","Kernel Density
Estimate"),lty=c(-1,1),lwd=c(-1,2),fill=c("lightblue"),merge=TRUE,inset=.01,cex=.8,adj=0)



Thx!  John

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to