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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:27:53+00:00 2026-05-30T09:27:53+00:00

I am creating a multi-plot layout illustration using R, and it would be convenient

  • 0

I am creating a multi-plot layout illustration using R, and it would be convenient to be able to create a multi-line text box in one of the plots.

I am familiar with using Sweave to combine images, text, and R code, however for various reasons I need this to be a single page plot produced in R. Thus the need to plot a text box rather than use Latex mark-up.

Is there a function in an existing package that can do this? Failing that, can anyone suggest a simple approach for handling this?

Consider this situation:

## Specify the dimensions of the plot
## that we require
win.graph(8,4)

## Two panel layout
layout(matrix(1:2, 1, 2))
par(mar=c(0,0,0,0))

## Left panel shows picture
plot(rep(1:10, each=10), rep(1:10, times=10), 
col=rainbow(100), pch=20, cex=5)


## Right panel discusses the data
plot.default(c(0,100), c(0,100), type="n", axes=FALSE,
ylab="", xlab="")

text(20, 30, "It would be great if this text box\n
could handle word wrap, and ideally given the size\n
of the font (i.e. the cex parameter) and the area\n
of the plot it should be able to do this dynamically,\n
without requiring the newline characters I am\n
manually inserting.  Ability to control the line\n
height would also be nice.\n
Am I dreaming?", cex=0.75, adj=c(0,0))

Output from example

  • 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-30T09:27:54+00:00Added an answer on May 30, 2026 at 9:27 am

    Try splitTextGrob() from the R graphics book

    text = paste(capture.output(licence()),collapse=" ")
    library(RGraphics)
    library(gridExtra)
    
    grid.arrange(rectGrob(), splitTextGrob(text), ncol=2)
    
    d <- expand.grid(seq(0.1, 0.9, length=10), seq(0.1, 0.9, length=10))
    grid.arrange(pointsGrob(d[, 2], d[, 1], pch=21, 
     gp=gpar(fill=rainbow(100))), splitTextGrob(text), ncol=2)
    

    enter image description here

    (try resizing the window)

    This approach being based on grid graphics, you can either

    • use lattice/ggplot2/grid for the plots

    • use the gridBase package to place base graphics within grid viewports

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

Sidebar

Related Questions

I'm creating additional module to already multi-module maven project. And for this one I
I'm creating a multi-tenant ASP.NET application using NHibernate (shared schema). I had intended to
When creating a multi-file unified diff is Index line required like in the following
I'm creating a multi layer project with a lot of different assemblies and using
I'm creating a multi-tenant Asp.Net MVC 3 Web app, and using EF4.1 code first
Background: I am creating a multi-language web application using Flash-builder 4. The menus and
I am creating a multi-layered image editor using AJAX to send calls to a
I'm creating a multi-player platform game in Cocos2D (objectiveC). I create dynamic bodies for
I am using JQueryUI Accordion for creating a Vertical Multi-level Menu with the following
I am creating Paths and adding multi lines in each path by using path.moveTo(x,

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.