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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:37:41+00:00 2026-06-01T08:37:41+00:00

Take a very simple example, mfrow=c(1,3) ; each figure is a different histogram; how

  • 0

Take a very simple example, mfrow=c(1,3); each figure is a different histogram; how would I draw a horizontal line (akin to abline(h=10)) that went across all 3 figures? (That is, even the margins between them.) Obviously, I could add an abline to each figure, but that’s not what I want. I can think of a very complicated way to do this by really only having 1 figure, and drawing each ‘figure’ within it using polygon etc. That would be ridiculous. Isn’t there an easy way to do this?

  • 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-01T08:37:43+00:00Added an answer on June 1, 2026 at 8:37 am

    As @joran noted, the grid graphical system offers more flexible control over arrangement of multiple plots on a single device.

    Here, I first use grconvertY() to query the location of a height of 50 on the y-axis in units of “normalized device coordinates”. (i.e. as a proportion of the total height of the plotting device, with 0=bottom, and 1=top). I then use grid functions to: (1) push a viewport that fills the device; and (2) plot a line at the height returned by grconvertY().

    ## Create three example plots
    par(mfrow=c(1,3))
    barplot(VADeaths, border = "dark blue") 
    barplot(VADeaths, border = "yellow") 
    barplot(VADeaths, border = "green") 
    
    ## From third plot, get the "normalized device coordinates" of 
    ## a point at a height of 50 on the y-axis.
    (Y <- grconvertY(50, "user", "ndc"))
    # [1] 0.314248
    
    ## Add the horizontal line using grid
    library(grid)
    pushViewport(viewport())
    grid.lines(x = c(0,1), y = Y, gp = gpar(col = "red"))
    popViewport()
    

    enter image description here

    EDIT: @joran asked how to plot a line that extends from the y-axis of the 1st plot to the edge of the last bar in the 3rd plot. Here are a couple of alternatives:

    library(grid)
    library(gridBase)
    par(mfrow=c(1,3))
    
    # barplot #1
    barplot(VADeaths, border = "dark blue") 
    X1 <- grconvertX(0, "user", "ndc")
    # barplot #2
    barplot(VADeaths, border = "yellow") 
    # barplot #3
    m <- barplot(VADeaths, border = "green") 
    X2 <- grconvertX(tail(m, 1) + 0.5, "user", "ndc") # default width of bars = 1
    Y <- grconvertY(50, "user", "ndc")
    
    ## Horizontal line
    pushViewport(viewport())
    grid.lines(x = c(X1, X2), y = Y, gp = gpar(col = "red"))
    popViewport()
    

    enter image description here

    Finally, here’s an almost equivalent, and more generally useful approach. It employs the functions grid.move.to() and grid.line.to() demo’d by Paul Murrell in the article linked to in @mdsumner’s answer:

    library(grid)
    library(gridBase)
    par(mfrow=c(1,3))
    
    barplot(VADeaths); vps1 <- do.call(vpStack, baseViewports())
    barplot(VADeaths) 
    barplot(VADeaths); vps3 <- do.call(vpStack, baseViewports())
    
    pushViewport(vps1)
    Y <- convertY(unit(50,"native"), "npc")
    popViewport(3)
    
    grid.move.to(x = unit(0, "npc"), y = Y, vp = vps1)
    grid.line.to(x = unit(1, "npc"), y = Y, vp = vps3, 
                 gp = gpar(col = "red"))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take a very simple case as an example, say I have this URL: http://www.example.com/65167.html
I have a java threads related question. To take a very simple example, lets
Take this very simple form for example: class SearchForm(Form): q = forms.CharField(label='search') This gets
Ok, I'm very simply trying to take this example... http://jsfiddle.net/shanabus/HGF59/ and put it on
Take for example an application which has users, each of which can be in
For example, take this code: $ch = curl_init($resultSet['url'].?get0=get0&get1=.$get1.&get2=.$get2.&get3=.$get3); This of course, looks very ugly,
I'm sure this is a very simple question but please take a look at
My question is very simple and can be understood in one line: Is there
I followed a very simple example of autocompletion using ajax and cannot get mine
I would like to do simple date calculations in Java. For example, compute the

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.