r - How to plot a colour wheel by using ggplot? -


i'm reading book "ggplot2 - elegant graphics data analysis" (wickham, 2009), section "scaling" (page 32) says this:

scaling involves mapping data values points in space. there many ways this, here since cyl categorical variable map values evenly spaced hues on colour wheel, shown in figure 3.4. different mapping used when variable continuous. result of these conversions table 3.4, contains values have meaning computer.

enter image description here

enter image description here

the book doesn't explain in detail how table 3.4, less figure 3.4. built-in database mpg. has idea how table , graph? in advance.

was wondering how without coord_polar(), since example wickham's book not. turns out can use geom_point(...).

library(ggplot2) r  <- seq(0,1,length=201) th <- seq(0,2*pi, length=201) d  <- expand.grid(r=r,th=th) gg <- with(d,data.frame(d,x=r*sin(th),y=r*cos(th),                         z=hcl(h=360*th/(2*pi),c=100*r, l=65))) ggplot(gg) +   geom_point(aes(x,y, color=z), size=3)+   scale_color_identity()+labs(x="",y="") +   coord_fixed() 

this renders in few seconds. this reference states default luminance, l=65.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -