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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:34:01+00:00 2026-06-12T06:34:01+00:00

I would like to centre a common legend below two plots. I have used

  • 0

I would like to centre a common legend below two plots. I have used xpd=TRUE to allow for printing outside the plot itself and oma to create space for the legend. However the legend will not move horizonatally and gets clipped ‘early’ vertically. Any advice?

quartz(title="PCoA",12,6)
par(mfrow=c(1,2),oma=c(5,0,0,0),xpd=TRUE)

plot(1:3,4:6,main="plot 1")

plot(1:3,4:6,main="plot 2")


# Clips the plot    
legend(1,3.5,ncol=3,c("0-1 km","1-5 km","outside barrier"),fill=c("green","orange","red"), title="Fetch")

# Won't let me move the legend sideways 
legend(0,3.5,ncol=3,c("0-1 km","1-5 km","outside barrier"),fill=c("green","orange","red"), title="Fetch")

enter image description here

UPDATE

With the solution below it cuts of the edge of the graph which becomes visible by changing the dimension of the figure by dragging the edge (see below). Any ideas what might be going on?

enter image description here

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-12T06:34:02+00:00Added an answer on June 12, 2026 at 6:34 am

    Rather than using par=mfrow(...) I suggest you use layout().

    This allows you to specify a matrix with plot positions:

    layout(matrix(c(1,2,3,3), ncol=2, byrow=TRUE), heights=c(4, 1))
    
    par(mai=rep(0.5, 4))
    plot(1:3,4:6,main="plot 1")
    plot(1:3,4:6,main="plot 2")
    
    par(mai=c(0,0,0,0))
    plot.new()
    legend(x="center", ncol=3,legend=c("0-1 km","1-5 km","outside barrier"),
           fill=c("green","orange","red"), title="Fetch")
    

    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 multiple points placed on my MapView and would like to centre the
I would like to know how to provide a common title and legend for
I have an iframe <iframe src=preloader.gif id=graphFrame...></iframe> . I would like to centre the
I have an aspx Login control and I would like to center it on
I have written a plugin for Windows 7 Media Center, and I would like
I would like C# code for determining the centre and radius of the circle
At our sports centre, I would like to analyse the number and types of
I would like to have a repeat-x on my body background for a web
I have a WPF datagrid and I would like to display a message saying
I have two modules like this (very very simplified): main.py: from window import *

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.