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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:47:31+00:00 2026-05-24T23:47:31+00:00

Creating the following plot results in the legend being placed vertically, on the right,

  • 0

Creating the following plot results in the legend being placed vertically, on the right, rather than on the bottom horizontally as indicated in the call to opts():

dat <- data.frame(x = runif(10), y = runif(10), 
                  grp = rep(letters[1:2],each = 5))

ggplot(data = dat, aes(x = x, y = y, colour = grp)) + 
  geom_point() + 
  opts(legend.position = "bottom", legend.direction = "horizontal") + 
  theme_bw()

enter image description here

How do I get the legend in the correct spot?

  • 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-05-24T23:47:32+00:00Added an answer on May 24, 2026 at 11:47 pm

    The problem is that that theme_bw() is placed after the call to opts(), and resets some defaults. Just place theme_bw() before opts():

    ggplot(data = dat, aes(x = x, y = y, colour = grp)) + 
      geom_point() + 
      theme_bw() +
      opts(legend.position = "bottom", legend.direction = "horizontal")
    

    Note: Since version 0.9.2 opts has been replaced by theme:

    theme(legend.position = "bottom", legend.direction = "horizontal")
    

    enter image description here

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

Sidebar

Related Questions

I am creating the following thread in my onCreate but realized that this call
I'm creating the following div using javascript, task_id is an int and person_name is
I'm creating JPopUpMenu with following code: JPopupMenu popup1 = new JPopupMenu(); JPopupMenu popup2 =
The mailing list form I am creating has the following fields: first name, last
When creating a string using the following notation: NSString *foo = @Bar; Does one
I'm creating a color object using the following code. curView.backgroundColor = [[UIColor alloc] initWithHue:229
I am creating several image dynamically using the following code: function refresh_gallery(galleryidentifier, albumid) {
I have the following code for creating tabs. It works at the end of
While creating the setup for VB.net application I am getting the following warning: Warning
I'm creating an MVC application that's following a RESTful URL approach. I am experiencing

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.