Skip to content

plotting with a table right under it

3 messages · david8373, Yihui Xie, Jim Lemon

#
Hi guys,

I'm new to R and this might be a basic question. I want to have a plot with
a table right under it containing all the data in the plot. Is that possible
in R? How do to it?

Thanks!

Yuhan
#
R is Not Excel, I think... But if you insist on "drawing" a table
below the graph, you may use rect() and text().

Why not add your numbers directly to your bars/lines/points/...? If
you can express the information in a table, why use a plot?

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China
On Sun, Sep 28, 2008 at 3:45 AM, david8373 <david8373 at gmail.com> wrote:
#
david8373 wrote:
Hi Yuhan,
Try this:

library(plotrix)
par(mfrow=c(2,1))
x<-rnorm(10)
y<-rnorm(10)
plot(x,y)
plot(0,xlim=c(-1,1),ylim=c(-1,1),type="n",
 axes=FALSE,xlab="",ylab="")
addtable2plot(-1,0.3,matrix(round(c(x,y),2),
 nrow=2,byrow=TRUE),
 display.colnames=FALSE)

Jim