Demo of Plotting Data from Tristimulus Colorimetry

Demo data from onion segregating at R locus

  • RR (dark red) or Rr(pale red) color, plus one brown in this sample rr
  • measured with Hunterlab in CIELAB space
library(colorspace)

rawdata=structure(list(Lstar = c(35.1, 30.61, 37.81, 43.91, 31.22, 42.97,
30.32, 37.61, 39.24, 49.63, 31.66, 27.32, 42.19, 49.11, 70.49,
39.49, 43.98, 36.58, 36.74, 42.33, 33.02, 34.03, 30.13, 34.54,
30.91, 31.5, 37.7, 21.03, 29.51, 44.31), Astar = c(21.58, 24.82,
20.18, 13.53, 26.3, 22.04, 26.49, 24.78, 21.73, 8.9, 28.69, 28.32,
20.52, 12.66, -6.91, 20.25, 21.21, 23.48, 25.1, 18.38, 22.4,
23.23, 30.8, 21.1, 32.8, 29.82, 25.52, 27.39, 27.96, 19.32),
Bstar = c(-8.7, -7.96, -6.61, -2.95, -8.89, -8.07, -9.22,
-8.92, -7.7, -1.37, -9.09, -9.1, -7.35, -4.27, 20.78, -6.24,
-7.64, -8.01, -9.2, -5.15, -6.06, -8.04, -8.88, -6.39, -9.99,
-9.22, -9.81, -3.83, -7.96, -7.28)), .Names = c("Lstar",
"Astar", "Bstar"), row.names = c(NA, 30L), class = "data.frame")
head(rawdata)
##   Lstar Astar Bstar
## 1 35.10 21.58 -8.70
## 2 30.61 24.82 -7.96
## 3 37.81 20.18 -6.61
## 4 43.91 13.53 -2.95
## 5 31.22 26.30 -8.89
## 6 42.97 22.04 -8.07

Create LAB colour S4 Object from LAB data

LABdata<- with(rawdata,LAB(Lstar,Astar,Bstar))
LABdata[1:6,]
##          L     A     B
## [1,] 35.10 21.58 -8.70
## [2,] 30.61 24.82 -7.96
## [3,] 37.81 20.18 -6.61
## [4,] 43.91 13.53 -2.95
## [5,] 31.22 26.30 -8.89
## [6,] 42.97 22.04 -8.07

Convert to hexdecimal colours using hex

hex(LABdata)
##  [1] "#6E4661" "#673955" "#744D64" "#7C606D" "#6A3958" "#835873" "#683756"
##  [8] "#794A67" "#795069" "#847179" "#6F3859" "#632E4F" "#7F5870" "#876E7C"
## [15] "#AFAF87" "#795168" "#855B75" "#754863" "#774766" "#7E596D" "#6B4058"
## [22] "#6E425D" "#6E3355" "#6D455C" "#723359" "#703759" "#794969" "#552039"
## [29] "#693452" "#835E75"

Plot points using these Colours with Base R

plot(as(LABdata,"LAB"))

Plot using ggplot

library(ggplot2)
ggplot(rawdata, aes(x=Astar, y=Bstar)) +
geom_point(size=5, aes(colour=hex(LABdata,fix = TRUE))) +
scale_color_identity()