



I resent this as I recognized that attachments are not allowed.

Dear ALL,

please find attached a small test file. (code is copied in this mail too)
Basically (as shown) I would like to combine several results in one graph.
I could succeed to plot the data correctly, but the legend generation does not fit.
For the dfStartPoints and the dfEndpoints I just want to be able to select the color AND (if possible the shape of each one)

The legend I'm getting could be modified for its title , but I was not able to to change the label value itself.

My final wish is to get 3 Legends (the one for dfXY is fully OK)
Legend one (Titled Cell/Area...) is fully OK as it is
Legend two should have Title "Start Point"s"  color "red" AND the count of data points as value
Legend three should have Tile Ënd Points color "green"AND the count of data points as value.

I think I can easily get the count , but I have no idea how to modify the related  legends in code

There are many examples of this (e.g. http://docs.ggplot2.org/current/guide_legend.html )  , but  nothing fits really.

Hope someone can help on this

Rolf

######################## code as attached ###############################
require(sqldf)
options(gsubfn.engine = "R")
require(ggplot2)

rm(list=ls(all=TRUE))
maxCells = max(primitiveDensityMap$c)

#craete a 100 * 100 grid with random values(cellCount)
dfXY <- data.frame(x=rep(0:99, each=100) , y=rep(0:99, each=1)  , cellCount=sample(0:99, 10000 , replace=T) )

dfStartPoints <- data.frame(x=sample(10:20, 3 , replace=T) , y=sample(30:40, 3 , replace=T)  )
dfEndPoints <- data.frame(x=sample(70:80, 3 , replace=T) , y=sample(90:100, 3 , replace=T)  )



nrow(dfXY)
#get max and min
maxCells = max(dfXY$cellCount)

ggplot(dfXY, aes(x=x,y=y)) +
	geom_tile(aes(fill= cellCount), as= 1) +
	labs(title="Primitive Cell Density", x="mm", y="mm") +
	scale_fill_continuous(  space= "Lab" , low="white", high="black" , breaks=seq(0,maxCells ,by=round(maxCells/10) ), guide = guide_legend( title =
"Cells/Area\n(100um^2)" ) ) +
	coord_fixed() +
	geom_point(data=dfStartPoints  , aes( colour="red"  ) ) +
	labs(color="Start Points" ) +
	geom_point(data=dfEndPoints  , aes( colour="green"  ) ) +
	labs(color="End Points" )

#######################################################################


Rolf  Kemper, Manager, Mixed Signal Design, Networking, Renesas Electronics Europe GmbH, , Arcadiastr. 10, 40472, Duesseldorf, Germany,  Phone:+49 211
6503-1475, Fax:+49 211 6503-1540, mailto:Rolf.Kemper@renesas.com, http://www.renesas.eu

This message is intended only for the use of the address...{{dropped:24}}

