[R] Create a colour scale for different data sets

BARLAS Marios 247554 Marios.BARLAS at cea.fr
Mon Jul 25 01:29:17 CEST 2016


Dear Jim,

Thanks for the advice! 

Turns out there was nothing wrong with my graphing code. I was just stupid when modifying the wafer map reconstruction code. If in the previous code you change this line : 

               dies.in.wafer.r[inn]      <- meas.data

to
              dies.in.wafer.r[inn]      <- meas.data[ixx]

It works perfectly. 

In case any1 else needs cartography mapping I will generalize this function, so feel free to ask for the code. 

Best,
Mario
________________________________________
From: Jim Lemon [drjimlemon at gmail.com]
Sent: Monday, July 25, 2016 12:17 AM
To: BARLAS Marios 247554
Subject: Re: [R] Create a colour scale for different data sets

Hi Marios,
One way to get a common color scale for a number of different sets of
values is the color.scale (plotrix) function. By setting the "xrange"
argument to the range of all values, the color for a particular value
will be the same in all subsets calculated. See the second example in
the "barp" help page. This might be what you want, where "x" is a
vector of your values:

color.scale(x,c(0.565,0.933,0.565),c(0,1,0), c(1,1,0),c(1,0,0),
 xrange=c(0,1e13))

Jim


On Mon, Jul 25, 2016 at 7:11 AM, BARLAS Marios 247554
<Marios.BARLAS at cea.fr> wrote:
> Hello Every1,
>
> I'm working on analysing some data and I want to make some cartography maps.
>
> Since I treat data in batch, I need to have a common reference colour scale for all the datasets I need to plot. This is important otherwise it becomes hard to quickly assert visually changes from one experiment to another if the colour scale resets all the time.
>
> So I though of finding the min and max value of my data values and create a colour scale versus that.
>
> Nonetheless the code does not work as intended,
> I realised my code was not easily reproducible so I send some with initialized values to help :)
>
> Here is a part of the code (reproducible):
>
> meas.data <- c( 2.38762e+02, 2.54709e+02, 2.45204e+02, 2.32134e+02, 2.28587e+02, 2.31493e+02, 2.34867e+02, 2.41127e+02, 2.76113e+02, 2.57450e+02, 2.23804e+02, 2.39064e+02, 2.28636e+02, 2.37417e+02, 2.53686e+02, 2.45593e+02, 2.29043e+02, 9.25698e+10, 2.31001e+02, 2.36022e+02, 2.67654e+02, 2.50275e+02, 2.72641e+02, 2.24342e+02, 9.36361e+10, 2.28610e+02, 2.20854e+02, 2.37955e+02, 2.58944e+02, 2.68088e+02, 2.36356e+02, 2.52802e+02, 2.32976e+02, 2.39819e+02, 2.48820e+02, 2.80206e+02, 2.63318e+02, 2.43431e+02, 2.83426e+02, 2.48557e+02, 2.45493e+02, 2.53264e+02, 2.51834e+02, 2.34187e+02, 2.56326e+02, 2.96419e+02, 2.52473e+02, 2.68144e+02, 2.40842e+02)
>
> die.codes <- c("X5_Y4"  , "X5_Y6" ,  "X5_Y8" ,  "X5_Y9", "X5_Y10", "X5_Y11", "X5_Y12", "X7_Y4", "X7_Y6", "X7_Y8", "X7_Y9", "X7_Y10", "X7_Y11", "X7_Y12", "X9_Y4", "X9_Y6", "X9_Y8", "X9_Y9", "X9_Y10", "X9_Y11", "X9_Y12", "X11_Y4", "X11_Y6", "X11_Y8", "X11_Y9", "X11_Y10", "X11_Y11", "X11_Y12", "X13_Y4", "X13_Y6", "X13_Y8", "X13_Y9",  "X13_Y10", "X13_Y11", "X13_Y12", "X15_Y4",  "X15_Y6",  "X15_Y8",  "X15_Y9",  "X15_Y10", "X15_Y11", "X15_Y12", "X17_Y4",  "X17_Y6", "X17_Y8" ,"X17_Y9",  "X17_Y10", "X17_Y11", "X17_Y12")
> dies.x.total <- 17
> dies.y.total <- 15
> r.max <- 1e13
>
>
>
>     dies.in.wafer <- expand.grid(X=as.numeric(1:dies.x.total), Y=as.numeric(1:dies.y.total))
>       # This procedure can be used to generate the patterns for the test labels as well. To be Tested and verified.
>       # Catch all numerical values in the string
>       # 4 Is the column for which the names of the die coordinates are stored
>       dies.tested <-strsplit(die.codes, "[^[:digit:]]")
>       # Convert to Numeric
>       dies.tested<- lapply(dies.tested,as.numeric )
>
>       dies.tested<- data.frame((matrix(unlist(dies.tested), ncol = dim.data.frame(dies.tested[[1]])[2], byrow = TRUE)))
>       # Drop all Columns containing NAs
>       dies.tested <- dies.tested[colSums(!is.na(dies.tested)) > 0]
>       dies.tested$test.order <- as.factor(1:dim.data.frame(dies.tested)[1])
>       colnames(dies.tested)  <- c("X","Y","Order")
>
>       dies.in.wafer.x <- dies.in.wafer$X
>       dies.in.wafer.y <- dies.in.wafer$Y
>       dies.in.wafer.tested <- rep(F, length = dim.data.frame(dies.in.wafer)[1])
>       dies.in.wafer.Order = rep(NA, length = dim.data.frame(dies.in.wafer)[1])
>       dies.in.wafer.r     = rep(NA, length = dim.data.frame(dies.in.wafer)[1])
>       dies.in.wafer.op    = rep(NA, length = dim.data.frame(dies.in.wafer)[1])
>
>       dies.tested.x <- dies.tested$X
>       dies.tested.y <- dies.tested$Y
>       dies.tested.order<- dies.tested$Order
>
>       dim.dies.in.wafer <- dim(dies.in.wafer)[1]
>       for(ixx in seq(1, dim(dies.tested)[1], by=1) ){
>         for (inn in seq(1, dim.dies.in.wafer, by=1) ){
>           if (dies.in.wafer.tested[inn]==F) {
>             dies.in.wafer.tested[inn] <- dies.tested.x[ixx] == dies.in.wafer.x[inn] & dies.tested.y[ixx] == dies.in.wafer.y[inn]
>             if (dies.in.wafer.tested[inn]==T) {
>               dies.in.wafer.Order[inn]  <- dies.tested$Order[ixx]
>               dies.in.wafer.r[inn]      <- meas.data
>               dies.in.wafer.op[inn]     <- op.type
>             }
>           }
>         }
>       }
>       dies.in.wafer$tested  <- dies.in.wafer.tested
>       dies.in.wafer$Order   <- dies.in.wafer.Order
>       dies.in.wafer$op.type <- as.factor(dies.in.wafer.op)
>       dies.in.wafer$R       <- dies.in.wafer.r
>
>
>       r.colour.map <- c("lightgreen", "darkgreen", "yellow","red" )
>       r.range.breaks <- c(0, 1.5e4, 1e5, r.max )/r.max
>       r.breaks.guide <- c(0, 1.5e4, 1e5, r.max )
>       g.map <- ggplot(dies.in.wafer, aes(X, Y)) +
>         geom_raster(aes(fill = R))+
>         scale_fill_gradientn(name="R", na.value = "grey50", colours = r.colour.map, values = r.range.breaks, breaks=r.breaks.guide, limits=c(0,r.max) )
>       g.map
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



More information about the R-help mailing list