Skip to content

How to make a plot?

3 messages · Gabor Grothendieck, JeeBee, Romain Francois

#
That can be done very easy using a program that can deal with layers,
for example the Gimp.
Just make one layer containing the barplot and one layer containing the
background image. Then you can do all kind of nice things.

Directly in R, I don't have a clue, but it wouldn't surprise me
if someone will show you an example ;)

JeeBee.
On Tue, 13 Dec 2005 08:32:15 -0500, Gabor Grothendieck wrote:

            
#
Le 13.12.2005 14:32, Gabor Grothendieck a ??crit :
Hi Gabor,

Here's a first draft.

The following code will produce a pdf (i only found transparancy support 
in pdf devices) which will be converted afterwards into a png file using 
(thanks to imageMagick) :

$ convert output.pdf output.png

Everything is there :
http://addictedtor.free.fr/misc/gabor/
Background image : http://addictedtor.free.fr/misc/gabor/cruise.pnm
Code : http://addictedtor.free.fr/misc/gabor/gabor.R
Pdf output : http://addictedtor.free.fr/misc/gabor/output.pdf
Png output : http://addictedtor.free.fr/misc/gabor/output.png

Romain

Code :
#########################################
require(pixmap)
require(grid)

x <- read.pnm('cruise.pnm')

pdf('output.pdf', width=6, height=4, version="1.4")

par(mar=c(0,0,0,0))

plot(x) # base graphics

y <- c(6, 6.5, 7, 8, 8.5, 8.2, 10, 9.6, 9.7, 9)
# some data like in the picture you gave


# now the grid stuff

pushViewport(viewport(xscale=c(0,10),
                      yscale=c(0,10)))

grid.rect(x=0:9,
          y=0,
          width=1,
          height=y,
          default.units="native",
          gp=gpar(fill="white", alpha=0.7, col="gray", lwd=2),
          just=c("left","bottom"))

grid.rect(x=0:9,
          y=y,
          width=1,
          height= unit(1, "npc") - unit(y, "native") ,
          default.units="native" ,
          gp=gpar(fill="white", col="white"), just=c("left","bottom"))

grid.lines(x=c(0,10), y=c(5, 5), default.units="native", gp=gpar(lwd=2, 
col="white", lty="dotted"))
 
grid.lines(x=c(0,10), y=c(10, 10), default.units="native", 
gp=gpar(lwd=2, col="gray", lty="dotted"))

popViewport()


dev.off()

#################################################