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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:14:14+00:00 2026-06-08T14:14:14+00:00

I have a simple data frame that I’m trying to do a combined line

  • 0

I have a simple data frame that I’m trying to do a combined line and point plot using ggplot2. Supposing my data looks like this:

df <- data.frame(x=rep(1:10,2), y=c(1:10,11:20), 
                 group=c(rep("a",10),rep("b",10)))

And I’m trying to make a plot:

g <- ggplot(df, aes(x=x, y=y, group=group))
g <- g + geom_line(aes(colour=group))
g <- g + geom_point(aes(colour=group, alpha = .8))
g

The result looks fine with one exception. It has an extra legend showing the alpha for my geom_point layer.

Extra Legend for <code>geom_point</code> transparency

How can I keep the legend showing group colors, but not the one that shows my alpha settings?

  • 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-08T14:14:17+00:00Added an answer on June 8, 2026 at 2:14 pm

    Aesthetics can be set or mapped within a ggplot call.

    • An aesthetic defined within aes(...) is mapped from the data, and a legend created.
    • An aesthetic may also be set to a single value, by defining it outside aes().

    In this case, it appears you wish to set alpha = 0.8 and map colour = group.

    To do this,

    Place the alpha = 0.8 outside the aes() definition.

    g <- ggplot(df, aes(x = x, y = y, group = group))
    g <- g + geom_line(aes(colour = group))
    g <- g + geom_point(aes(colour = group), alpha = 0.8)
    g
    

    enter image description here

    For any mapped variable you can supress the appearance of a legend by using guide = 'none' in the appropriate scale_... call. eg.

    g2 <- ggplot(df, aes(x = x, y = y, group = group)) + 
            geom_line(aes(colour = group)) +
            geom_point(aes(colour = group, alpha = 0.8))
    g2 + scale_alpha(guide = 'none')
    

    Which will return an identical plot

    EDIT
    @Joran’s comment is spot-on, I’ve made my answer more comprehensive

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

Sidebar

Related Questions

I have a very simple problem. I have a data frame with multiple rows
i am trying to run a simple multiplication of a data.frame column with a
I've got a nice facet_wrap density plot that I have created with ggplot2 .
Say we have the following simple data-frame of date-value pairs, where some dates are
i have a simple example of a JList that is getting it's data from
I have a data.frame that contains historic data by day for several months. I
I have a fairly simple data.frame dput(x), below: x <- structure(list(variable = c(a, b,
I have a data frame that follows the below long Pattern: Name MedName Name1
I have a for loop that populates values into a data frame named Df.
This should be simple but for some reason I'm stuck. I have data that

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.