Product: TIBCO Spotfire®
How to print regular command line graph and a trellis graph to the same page.
How can I combine a trellis plot and a regular command line graph onto the same graphsheet page?
You will need to set up the plotting regions for the trellis plots and the command line plots separately and specify where each graph is to print on the page. The command line graphs (like plot) use split.screen() to set up their plotting regions on a page and the trellis graphs (like bwplot), use the split argument in print.trellis(). For example:
# Set up and plot the split screens and
# command line graphs
split.screen(c(2,1)) # split into upper and lower half
split.screen(c(1,2),screen=2) # split the lower half to two subscreens
# Print in the upper half
screen(1)
# Create data to plot
a<-rnorm(10,0,1)
b<-rnorm(10,0,1)
data<-data.frame(x=c(a,b),lab=c(rep("1",10),rep("2",10)))
plot(seq(1,10),a)
# Print in the right panel of the lower half
screen(4)
plot(seq(1,10),a)
# Close the screen when done
close.screen(all = T)
# Now set par(new=T) to allow a new graph to be added
par(new=T)
# Then plot the trellis graph
# in the left panel of the lower half
x <- bwplot(lab~x, data=data)
# This split argument says to create a 2x2 matrix of plotting regions
print.trellis(x, split=c(1,1,2,2))
References:
You can read about split.screen() and print.trellis() in their respective help files:
> ?split.screen
> ?print.trellis
Comments
0 comments
Article is closed for comments.