[R] how to set chart output size in rgl (surface3d)?

Duncan Murdoch murdoch.duncan at gmail.com
Sat May 1 05:35:02 CEST 2010


On 30/04/2010 9:01 PM, Mandy Xu wrote:
> i tried using your suggestion but still can't manipulate the dimensions such
> that the chart fills the whole window. i've attached the picture i get when
> i tried your suggested method. as you can see, there's still a lot of white
> space around it.
>
> is there anyway i can:
> a) output to png ONLY the 3d chart, NOT the a screenshot of the whole
> window? or
>   

The rgl.snapshot function will only save the whole window.
> b) set the dimensions of the 3d chart so it COMPLETELY fills the window such
> that there won't be any white space? or
>   

You can zoom in to eliminate the white space, but since the outline of 
your figure is not rectangular, you'll lose things like the axes and 
edges of your figure.
> c) anyway to crop pictures in R?
>   

R isn't an image editor, but I imagine you could convert an image into 
an array, select a subset of the array, and then convert back to an 
image.  But you'd be better off cropping in an image editor.

Duncan Murdoch
> thanks again!! i've racked my brains trying to do this for over a week now,
> and still no solution...
>
> On Mon, Apr 26, 2010 at 10:31 PM, Duncan Murdoch
> <murdoch.duncan at gmail.com>wrote:
>
>   
>> Mandy Xu wrote:
>>
>>     
>>> Hi R users,
>>>
>>> Does anyone know how to change the size of 3d charts? I'm using surface3d
>>> in
>>> rgl package, opening a new window each time to display the chart. I want
>>> it
>>> so that the chart fills the whole window, because when I output it to png,
>>> I
>>> don't want all the white space around the chart (right now, i'm getting
>>> this
>>> white "border" around the chart because the chart is smaller than the
>>> window).
>>>
>>> I know how to set the size of the window, but not the chart. When I make
>>> the
>>> window smaller, the chart automatically resizes so it gets even smaller.
>>> Is
>>> there a way to set the chart output size so it fills all (or most) of the
>>> window?
>>>
>>>       
>> Open a window, resize it to the look you want (the right button resizes),
>> then save the par3d("zoom") value into r3dDefaults$zoom.  That will be the
>> default zoom for new windows you open using open3d.  (You may also want to
>> save par3d("userMatrix") into r3dDefaults$userMatrix, if you want to change
>> the orientation of the default view.)
>>
>> Duncan Murdoch
>>
>>     
>
>



More information about the R-help mailing list