Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9270617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:24:55+00:00 2026-06-18T15:24:55+00:00

I am trying to replicate figure 6.11 from Hadley Wickham’s ggplot2 book , which

  • 0

I am trying to replicate figure 6.11 from Hadley Wickham’s ggplot2 book, which plots R colors in Luv space; the colors of points represent themselves, and no legend is necessary.
enter image description here

Here are two attempts:

library(colorspace)
myColors <- data.frame("L"=runif(10000, 0,100),"a"=runif(10000, -100, 100),"b"=runif(10000, -100, 100))
myColors <- within(myColors, Luv <- hex(LUV(L, a, b)))
myColors <- na.omit(myColors)
g <- ggplot(myColors, aes(a, b, color=Luv), size=2)
g + geom_point() + ggtitle ("mycolors")

enter image description here

Second attempt:

other <- data.frame("L"=runif(10000),"a"=runif(10000),"b"=runif(10000))
other <- within(other, Luv <- hex(LUV(L, a, b)))
other <- na.omit(other)
g <- ggplot(other, aes(a, b, color=Luv), size=2)
g + geom_point() + ggtitle("other")

enter image description here

There are a couple of obvious problems:

  1. These graphs don’t look anything like the figure. Any suggestions on
    the code needed?
  2. The first attempt generates a lot of NA fields in the Luv
    column (only ~3100 named colors out of 10,000 runs, versus ~9950 in
    the second run). If L is supposed to be between 0-100 and u and v
    between -100 and 100, why do I have so many NAs in the first run? I have tried rounding, it doesn’t help.
  3. Why do I have a legend?

Many thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:24:56+00:00Added an answer on June 18, 2026 at 3:24 pm

    You’re getting strange colors because aes(color = Luv) says “assign a color to each unique string in column Luv“. If you assign color outside of aes, as below, it means “use these explicit colors”. I think something like this should be close to the figure you presented.

    require(colorspace)
    x <- sRGB(t(col2rgb(colors())))
    storage.mode(x@coords) <- "numeric" # as(..., "LUV") doesn't like integers for some reason
    y <- as(x, "LUV")
    DF <- as.data.frame(y@coords)
    DF$col <- colors()
    ggplot(DF, aes( x = U, y = V)) + geom_point(colour = DF$col)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to replicate Hadley Wickham's example on page 86 of the ggplot2
Im trying to replicate the following sql in Nhibernate ICriteria SELECT DISTINCT AP.ID FROM
I am trying to replicate a table produced from a sybase database, I dont
I am trying to replicate the results from a paper. Two-dimensional Fourier Transform (2D-FT)
I'm trying to basically replicate the Starbucks mobile navigation but I can't figure out
I'm trying to figure out how to migrate data from one cassandra cluster, to
I'm trying to replicate a function which uses this pattern matching in the codes
Trying to replicate the docking controls in Visual Studio 2008. My application replays the
Im trying to replicate an effect as seen on http://www.fiat.co.uk/Showroom/#showroom/punto_evo/explore . I have made
I am trying to replicate the example, given in Statistical Models in S .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.