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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:20:56+00:00 2026-06-05T23:20:56+00:00

Could someone help me to add A-atype B-btype C-ctype ONLY as a legend to

  • 0

Could someone help me to add A-atype B-btype C-ctype ONLY as a legend to the below qplot graph. My legend should be on the top of the graph and also it should be horizontal. Please also see below for the data and the qplot code I am using for generating the graph.

Data:

type    name    value
A john  47.6
B john  55.6
C john  57.7
A amy   13.15
B amy   23.1
C amy   24.9
A lily  14.0
B lily  18.1
C lily  21.9
A sam   38.8
B sam   44.8
C sam   45.9
A frank 63.6
B frank 64.4
C frank 64.7
A xia   52.8
B xia   54.1
C xia   56.4
A yan   53.8
B yan   56.1
C yan   58.6

Code:

qplot(type, value, geom="bar", fill=c(""),data=temp, group=name,
  facets= .~name,stat="identity")
+ theme_bw()             
+ opts(axis.title.y=theme_text(size=16,angle=90),axis.title.x=theme_text(size=16,angle=0))
+ opts(axis.text.x=theme_text(size=10))   
+ opts(axis.text.y=theme_text(size=14))    
+ opts(strip.background = theme_rect(colour = 'steelblue', fill = 'white', size = 2))  
+ opts(legend.title=theme_blank())  
+ opts(legend.position="top")

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-05T23:20:58+00:00Added an answer on June 5, 2026 at 11:20 pm

    Is it something like this you’re after? First, draw the legend, then remove the coloured key of the legend. fill = type draws the legend. scale_fill_manual ensures the bars have the same colour, and inserts the desired labels in the legend. guides removes the coloured keys, or rather it colours the keys white, leaving just the legend labels. Probably, fill = NA in the call to guides would work too.
    EDIT: updated code for ggplot2 version 2

    library(ggplot2)
    
    temp = read.table(text = "
    type    name    value
    A john  47.6
    B john  55.6
    C john  57.7
    A amy   13.15
    B amy   23.1
    C amy   24.9
    A lily  14.0
    B lily  18.1
    C lily  21.9
    A sam   38.8
    B sam   44.8
    C sam   45.9
    A frank 63.6
    B frank 64.4
    C frank 64.7
    A xia   52.8
    B xia   54.1
    C xia   56.4
    A yan   53.8
    B yan   56.1
    C yan   58.6", header = TRUE, sep = "")
    
    
    qplot(type, value, geom="col", fill=type, data=temp, group=name, facets= .~name) + 
       scale_fill_manual(values = rep("salmon",3), labels = c("A - atype", "B - btype", "C - ctype")) +
       guides(fill = guide_legend(override.aes = list(fill = "white"))) +
       theme_bw() + 
       theme(axis.title.y=element_text(size=16,angle=90),
             axis.title.x=element_text(size=16,angle=0), 
             axis.text.x=element_text(size=10), 
             axis.text.y=element_text(size=14), 
             strip.background = element_rect(colour = 'steelblue', fill = 'white', size = 2),
             legend.title=element_blank(), 
             legend.position="top", 
             legend.key = element_rect(colour = NA))
    

    enter image description here

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

Sidebar

Related Questions

could someone help me how to add this selected line which you can see
Could someone help me to write a function that checks if a string is
Could someone help me to write a logic that converts a ID array to
could someone help me on this problem, i want to access facebook API through
could someone help me with the regex pattern that i could use to match
Could someone help me on this, I have created simple web services using axis2
Could someone help me clarify the following conecpts, and the relationship among them ?
Could someone help me out? it's probably something simple i'm overlooking: <script src=http://jqueryui.com/ui/jquery.ui.core.js></script> <script
Could someone help me understand the primitive accessors with this example : i don't
Please could someone help me understand why the div.fl element shown in Developer Tools

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.