[R] margins and device: different results with pdf() and svg()

Agustin Lobo aloboaleu at gmail.com
Wed Mar 5 13:52:01 CET 2014


The following works fine with either the plot window or a pdf device:

pdf("test.pdf",width=12,height=8)
par(mar=c(5,4,4,5))
plot(421:450,1:30,xlim=c(300,1100), ylim=c(0,100),
type="l",col="blue",xlab="Wavelength",ylab="Transmittance %")
lines(401:1000, (401:1000)/10,col="green")
par(new=TRUE)
axis(4)
mtext("Reflectance",side=4,line=3)
title("Filters MCA01")
dev.off()

but if I use svg() I get a wrong plot.

Why? Any way to get the same plot in svg as in pdf?

Thanks
Agus

> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
LC_TIME=es_ES.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=es_ES.UTF-8    LC_MESSAGES=en_US.UTF-8
LC_PAPER=es_ES.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] MASS_7.3-29     reshape_0.8.4   plyr_1.8        ggplot2_0.9.3.1
raster_2.2-12   rgdal_0.8-14    sp_1.0-14

loaded via a namespace (and not attached):
 [1] colorspace_1.2-4   dichromat_2.0-0    digest_0.6.4
grid_3.0.2         gtable_0.1.2       labeling_0.2
 [7] lattice_0.20-24    munsell_0.4.2      proto_0.3-10
RColorBrewer_1.0-5 reshape2_1.2.2     scales_0.2.3
[13] stringr_0.6.2      tools_3.0.2



-- 
Agustin Lobo
aloboaleu at gmail.com



More information about the R-help mailing list