Skip to content
Prev 22604 / 398502 Next

Attaching marginal summary plots to the main matrix plot

attach
hand
the
well.
If I correctly understand what you are trying to do, the way to do this
would be to use par("fig"), which adjusts the size of the plot region
within the current device.

par(mfrow) and par(mfcol) result in the device being split up into
equally sized plot regions, which does not achieve what I think you
want.

Below is some code as an example.  I am using barplot() for the row and
column sum plots in the example.  This may or may not be how you want
these plotted.

I will leave the fine tuning of the plot types, sizes, axis ranges,
labels, row/column alignments, etc. for you. This should give you a
conceptual feel for how to go about it.

HTH.

Marc

------------------

#define matrix
dat <- matrix(rnorm(1000), nrow = 25)

# save the current parameters 
op <- par(no.readonly = TRUE) 


# open a new plot window 
plot.new() 


# adjust the plot region size for each area
# the LL and UR corners of the default region are (0,0) and (1,1) 
# par("fig") is (x1, x2, y1, y2) 


# first set the region for the larger plot at the bottom 
# note that the dimensions will overlap a bit in each region
par(fig = c(0.0, 0.75, 0.0, 0.75)) 


# now draw the larger plot 
image(dat)


# do not overwrite the current plot 
par(new = TRUE) 


# now set the second region for the small plot at the top 
par(fig = c(0.0, 0.75, .65, 1.0)) 

# plot the colSums
barplot(colSums(dat))


# do not overwrite the current plot 
par(new = TRUE) 


# now set the third region for the small plot to the right 
par(fig = c(0.65, 1.0, 0.0, 0.75)) 

# plot the rowSums
barplot(rowSums(dat), horiz = TRUE)


# restore the original parameters 
par(op) 



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._