Thanks to both, Agustin and Adam for your useful comments.

trying:
plot(px > threshold, main="",colNA="transparent", ext=ext) # px is the
raster model
png("graph.png",
         width = 1500, height = 960, units = "px")
par(bg = "transparent")
dev.off()

did not allow me to open the graph until i closed the rstudio

In the end,  what worked best for me was to use:


plot(px > threshold, main=name, ext=ext)
dev.copy(png,"graph.png",
         width = 1500, height = 960, units = "px")
par(bg = "transparent")
dev.off()

However, despite this script worked for plotting a phylogenetic tree with
transparent background, i am still not able to generate a raster plot with
transparent background.

Many thanks!
Agus
2012/7/25 Adam Sparks <adamhsparks@gmail.com>

> Dear Agus,
> I'd suggest using the pdf() or png() functions in your script, rather than
> relying on RStudio's exporting.
>
> This way you can specify the size.
>
> best,
> Adam
>
>
>
> On Wed, Jul 25, 2012 at 8:36 AM, Agus Camacho <agus.camacho@gmail.com>wrote:
>
>> Dear all,
>>
>> I am trying to change the size to raster maps generated in R. However, the
>> differently layers separate when i do this.
>> Any body knows if its possible and how to avoid this?
>> Thanks
>> There it goes an reproducible example
>>
>> alt <- getData('alt', country='CHE')
>> slope <- terrain(alt, opt='slope')
>> aspect <- terrain(alt, opt='aspect')
>> hill <- hillShade(slope, aspect, 40, 270)
>> plot(hill, col=grey(0:100/100), legend=FALSE, main='Switzerland')
>> plot(alt, col=rainbow(25, alpha=0.35), add=TRUE)
>>
>> Then, use image export or save in pdf, or zoom options in Rs tudio to
>> change the size of the file.
>>
>> Thanks in advance.
>> Agus
>>
>> --
>> Agustín Camacho Guerrero.
>> Doutorando em Zoologia.
>> Laboratório de Herpetologia, Departamento de Zoologia, Instituto de
>> Biociências, USP.
>> Rua do Matão, trav. 14, nº 321, Cidade Universitária,
>> São Paulo - SP, CEP: 05508-090, Brasil.
>>
>>         [[alternative HTML version deleted]]
>>
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>>
>
>
> --
> --
> Adam Sparks
> Plant Pathologist and GIS Specialist
> IRRI
> DAPO Box 7777, Metro Manila, Philippines
> ph: +63(2) 580-5600
>
>
>


-- 
Agustín Camacho Guerrero.
Doutorando em Zoologia.
Laboratório de Herpetologia, Departamento de Zoologia, Instituto de
Biociências, USP.
Rua do Matão, trav. 14, nº 321, Cidade Universitária,
São Paulo - SP, CEP: 05508-090, Brasil.

	[[alternative HTML version deleted]]

