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

  • Home
  • SEARCH
  • 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 9212269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:29:07+00:00 2026-06-18T01:29:07+00:00

I have the following plot like below. It was created with this command: library(ggplot2)

  • 0

I have the following plot like below. It was created with this command:

library(ggplot2)

df <- data.frame(cond = factor(rep(c("A", "B"), each = 200)), 
                 rating = c(rnorm(200), rnorm(200, mean=.8)))

ggplot(df, aes(x=rating, fill=cond)) + 
geom_density(alpha = .3) +
xlab("NEW RATING TITLE") +
ylab("NEW DENSITY TITLE")

Now, I want to modify the legend title from cond into NEW LEGEND TITLE.

So, I just added the following line add the end of the above code:

+labs(colour="NEW LEGEND TITLE")

But it doesn’t work. What’s the right way to do it?

enter image description here

  • 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-18T01:29:09+00:00Added an answer on June 18, 2026 at 1:29 am

    This should work:

    p <- ggplot(df, aes(x=rating, fill=cond)) + 
               geom_density(alpha=.3) + 
               xlab("NEW RATING TITLE") + 
               ylab("NEW DENSITY TITLE")
    p <- p + guides(fill=guide_legend(title="New Legend Title"))
    

    (or alternatively)

    p + scale_fill_discrete(name = "New Legend Title")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following plot: library(ggplot2) ib<- data.frame( category = factor(c(Cat1,Cat2,Cat1, Cat1, Cat2,Cat1,Cat1, Cat2,Cat2)),
I have the following data set that I am trying to plot with ggplot2,
If I have the following data and plot it using ggplot2 I get: a
I have the following network diagram: set.seed(1410) df<-data.frame( site.x=c(rep(a,4),rep(b,4),rep(c,4),rep(d,4)), site.y=c(rep(c(e,f,g,h),4)), bond.strength=sample(1:100,16, replace=TRUE)) library(igraph) df<-graph.data.frame(df)
I have the following plot of data: I would like to have month labels
I have several file with the following format: lat,lon,value. I would like to plot
I have the following data frame: id variable value ID1 1A 91.98473282 ID1 2A
In a ggplot2 density plot (geom_density) I have the following y-axis labels 0.000 0.005
I have created a 3d map using rgl.surface(), mainly following Shane's answer in this
I have the following data frame: structure(list(X1 = structure(c(1L, 1L, 1L, 1L, 1L, 1L,

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.