[R] png raster in 3D chart

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Sun Oct 31 12:09:19 CET 2021


On 30/10/2021 5:48 p.m., Cleber Borges via R-help wrote:
> After a lot of testing and reading the manuals, I think I came pretty
> close to what I wanted (code below).
> 
> But some Cartesian axes do not appear.
> 
> I placed each axis separately and the corners where the raster images
> coincide overlapping the axes. The others have no problems.
> 
> 
> Many thanks,
> 
> Cleber
> 
> ######################
> 
> 
> library( rgl ); library( grid ); library( jpeg )
> 
> Rlogo <- "C:/R/doc/html/logo.jpg"

That won't work on most systems.  Please use something like

Rlogo <- file.path(R.home(), "doc/html/logo.jpg")


> logo <- readJPEG( Rlogo )
> 
> open3d( ); view3d( theta=300, phi=15, zoom=1.2 )
> 
> show2d({ par(mar=c(0,0,0,0));
> grid.raster(logo,0.5,0.5,.80,.80,"center")}, face="xx", rev=1)
> show2d({ par(mar=c(0,0,0,0));
> grid.raster(logo,0.5,0.5,.80,.80,"center")}, face="y-", rev=1)
> show2d({ par(mar=c(0,0,0,0));
> grid.raster(logo,0.5,0.5,.80,.80,"center")}, face="z-")
> 
> box3d( floating=NA  )

I don't think that has ever worked.  "floating=NA" is a special value 
that means something in mtext3d() and related function, but it's not a 
legal value for floating in general.

> axes3d( c("x","x-+","x+-","y","y++","z","z--","z++"), tick=FALSE,
> labels=FALSE, expand=1.1 )
>

I don't understand what you are trying to accomplish with this.  There 
are 12 possible locations for axes; this draws 7 of them (since "z" and 
"z--" mean the same thing).  Maybe this is why you aren't seeing some axes?

Another possibility is "z-fighting".  If you try to draw two 3D objects 
at the exact same location, only one will be displayed, and it's hard to 
predict which.  Rounding error sometimes goes one way, sometimes the 
other.  You can mitigate this by using the "polygon_offset = 1" material 
property on the polygons drawn by show2d().

Duncan Murdoch



More information about the R-help mailing list