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 8705179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:17:41+00:00 2026-06-13T03:17:41+00:00

I have a dataset with 224900 observations and 10 variables which are the result

  • 0

I have a dataset with 224900 observations and 10 variables which are the result of different Taylor series back transformations to original data values. I wish to overlay the density plots of each of these 10 variables to show the level of robustness of the Taylor series back transformation on the data estimates. Rather than having just 10 lines, I thought it would be good to have a colour apply, so that each density plot contributes 10% of a grey scale. Where there is data that just relates to one of the plots, there would be 10% grey, two plots would be twice as dark at 20%, up to where all the density plots overlap, which would be 100%.

I have used melt to get a dataframe that is 2249000 rows long. There are three columns, the first is the person ID, the second is the grouping variable (variable), and the third is the value of daily kJ intake (value).

I have used the following code to overlay the density plots in ggplot2 but it uses different colours for the groups. How can I change this code to get my grey scale? I want all 10 groups to have the same colour and colour density; the purpose of the plot is simply to to visually show the amount of overlap on the density plot using greyscale.

ggplot(Energy, aes(x=value, fill=variable)) + geom_density(alpha = 0.5)

Some test data to play with for those wishing to help, using 5 groups and not 10:

variable <- c(rep("A",100), rep("B",100), rep("C",100), rep("D",100), rep("E",100))
value <- c(rnorm(100,5000,200), rnorm(100,5050,210), rnorm(100,5100,215), 
           rnorm(100,5150,220), rnorm(100,5200,225))
MyData <- cbind.data.frame(value, variable)
ggplot(MyData, aes(x=value, fill=variable)) + geom_density(alpha = 0.5)

I think the answer may be associated with modifying scale_colour_grey and/or scale_manual but I don’t understand enough to work this out myself.

  • 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-13T03:17:42+00:00Added an answer on June 13, 2026 at 3:17 am

    This can be done by using a group aesthetic and making the fill for the density a light shade of grey like gray10 or gray20:

    ggplot(MyData, aes(x=value, group=variable)) + geom_density(alpha = 0.5, fill="gray20")
    

    Which will give you:

    Density plot

    In your case you probably want gray10, since you have 10 groups, rather than the 5 that are plotted here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have DataSet which has 3 columns. Name - insurance comp. name - treatmentDate
I have a dataset and I write it's values to an excel file using
I have a dataset which I want to use as a parameter for my
I have a DataSet which contains two tables, Publication and Owner, which are linked
I have a dataset for which I have extracted the date at which an
I have dataset function which is as below, public DataSet GetUpodBrandList(string criteria, string locationId)
I have a dataset which I'd like to consume with tbb::parallel_for in intervals of
I have two dataset (each has two columns of data). I want to use
I have a dataset composed of values obtained from studies and experiments. Experiments are
I have a DataSet that contains a column, call it Type which contains ints.

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.