[R] plot and save as png

Sarah Goslee sarah.goslee at gmail.com
Thu Mar 21 20:18:24 CET 2013


Hi,

So when you run the code suggested:

png(filename = "fname.png", width = 900, height = 600, units = 'px')
layout(matrix(c(1,2,3,4), 4, 1, byrow = TRUE))
plot(sin, -pi, 10*pi)
plot(sin, -pi, 20*pi)
plot(sin, -pi, 30*pi)
plot(sin, -pi, 40*pi)
dev.off()

exactly like that, you do not get a file named fname.png in your
working directory?

Do you get an error message, or any other information from the R console?

Sarah

On Thu, Mar 21, 2013 at 1:55 PM, veepsirtt <veepsirtt at gmail.com> wrote:
> Hi A.K
>
> This is working
> layout(matrix(c(1,2,3,4), 4, 1, byrow = TRUE))
> plot(sin, -pi, 10*pi)
>  plot(sin, -pi, 20*pi)
>  plot(sin, -pi, 30*pi)
> plot(sin, -pi, 40*pi)
> dev.off()
> but if I add this line
> png(filename = "fname.png", width = 900, height = 600, units = 'px')
>  no plot is generated.
> where is the problem?.
>
> thanks
> veepsirtt
>
>
>
>> png(filename = "fname.png", width = 900, height = 600, units = 'px')
>> layout(matrix(c(1,2,3,4), 4, 1, byrow = TRUE))
>> plot(sin, -pi, 10*pi)
>>  plot(sin, -pi, 20*pi)
>>  plot(sin, -pi, 30*pi)
>> plot(sin, -pi, 40*pi)
>> dev.off()
> null device
>           1
>> sessionInfo()
> R version 2.15.1 (2012-06-22)
> Platform: i386-pc-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=English_United States.1252
> [2] LC_CTYPE=English_United States.1252
> [3] LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> loaded via a namespace (and not attached):
> [1] tools_2.15.1
>>
>
>
> On Mon, Mar 18, 2013 at 6:36 PM, arun kirshna [via R] <
> ml-node+s789695n4661660h40 at n4.nabble.com> wrote:
>
>> Hi,
>>
>> Couldn't reproduce your problem.
>> Using your code, I am getting the image below:
>> A.K.
>>
>
>

--
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list