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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:51:03+00:00 2026-05-28T07:51:03+00:00

I have a plot that has data that runs into the area I’d like

  • 0

I have a plot that has data that runs into the area I’d like to use for a legend. Is there a way to have the plot automatically put in something like a header space above the highest data points to fit the legend into?

I can get it to work if I manually enter the ylim() arguments to expand the size and then give the exact coordinates of where I want the legend located, but I’d prefer to have a more flexible means of doing this as it’s a front end for a data base query and the data levels could have very different levels.

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-05-28T07:51:04+00:00Added an answer on May 28, 2026 at 7:51 am

    Edit 2017:

    use ggplot and theme(legend.position = “”):

    library(ggplot2)
    library(reshape2)
    
    set.seed(121)
    a=sample(1:100,5)
    b=sample(1:100,5)
    c=sample(1:100,5)
    
    df = data.frame(number = 1:5,a,b,c)
    df_long <- melt(df,id.vars = "number")
    ggplot(data=df_long,aes(x = number,y=value, colour=variable)) +geom_line() +
    theme(legend.position="bottom")
    

    Original answer 2012:
    Put the legend on the bottom:

    set.seed(121)
    a=sample(1:100,5)
    b=sample(1:100,5)
    c=sample(1:100,5)
    
    dev.off()
    
    layout(rbind(1,2), heights=c(7,1))  # put legend on bottom 1/8th of the chart
    
    plot(a,type='l',ylim=c(min(c(a,b,c)),max(c(a,b,c))))
    lines(b,lty=2)
    lines(c,lty=3,col='blue')
    
    # setup for no margins on the legend
    par(mar=c(0, 0, 0, 0))
    # c(bottom, left, top, right)
    plot.new()
    legend('center','groups',c("A","B","C"), lty = c(1,2,3),
           col=c('black','black','blue'),ncol=3,bty ="n")
    

    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 have a data set that has two tab delimited columns that I plot
I often run into an issue where I have a data frame that has
I have the following data set that I am trying to plot with ggplot2,
I have a scatter plot in R (with ggplot2). The data has a numeric
I have two sets of data, (Ax, Ay; Bx, By). I'd like to plot
I have a csv that I have imported that has multiple data fields for
I have a table that has two columns both of them are continuous data.
I have some data that I want to plot in MATLAB. The data consists
I have multiple vectors of varying lengths that I would like to plot next
I have a plot (sample code pasted below) that I am trying to add

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.