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" )

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

(See attached file: R_test.PNG)(See attached file: help_test_2.r)

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.kem...@renesas.com, 
http://www.renesas.eu

This message is intended only for the use of the addressee(s) and may contain 
confidential and/or legally privileged information. If you are not the
intended recipient, you are hereby notified that any dissemination of this 
email (including any attachments thereto) is strictly prohibited. If you
have received this email in error, please notify the sender immediately by 
telephone or email  and permanently destroy the original without making any
copy. Please note that any material and advice from this mail is provided free 
of charge and shall be used as an example for demonstration purposes
only.
RENESAS MAKES NO WARRANTIES THAT THE USAGE OF INFORMATION OR ADVICE FROM THIS 
E-MAIL WILL NOT INFRINGE ANY INTELLECTUAL PROPERTY RIGHTS (E.G. PATENTS,
COPYRIGHTS). RENESAS CANNOT GUARANTEE BUG FREE OPERATION AND THE RECIPIENT WILL 
USE AND/OR DISTRIBUTE IT ONLY AT HIS OWN RISK. IN NO EVENT SHALL
RENESAS BE LIABLE FOR ANY DAMAGE.  The communication with Renesas Electronics 
Europe GmbH does not amend any written agreement in place. Renesas
Electronics Europe GmbH

Geschaeftsfuehrer/Managing Director: Robert Green Sitz der 
Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 
Duesseldorf, Germany
Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax 
identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
______________________________________________
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