Scale_color_manual not working as expected

后端 未结 1 1903
野的像风
野的像风 2021-01-25 15:00

I am using the following piece of code to create a bar graph:

temp1 <- melt(final,id=\'Time\')
p <- ggplot(temp1, aes(x=Time, y=value, fill=variable)) +
           


        
1条回答
  •  北海茫月
    2021-01-25 15:21

    There is no reproducible data. I, therefore, created a simple data here. I also simplified the code of the OP. What is necessary here is scale_fill_manual.

    mydf <- data.frame(time = letters[1:3],
                       variable = LETTERS[1:3],
                       value = runif(3, 10, 15),
                       stringsAsFactors = FALSE)
    
    
    ggplot(mydf, aes(x=time, y=value, fill=variable)) +
      geom_bar(stat="identity") +
      scale_fill_manual(values=c("#a6cee3","#1f78b4","#b2df8a"))
    

    enter image description here

    0 讨论(0)
提交回复
热议问题