[R] 3D or 4D plot
Duncan Murdoch
murdoch at stats.uwo.ca
Fri Feb 20 19:55:05 CET 2009
On 2/20/2009 1:46 PM, kapo coulibaly wrote:
> Ideally I would want it to look like a rubik cube with each little cube
> color coded based on the fourth column (data column). Your suggestion might
> work if I could color code based on data in the fourth column.
> Thanks
There's no primitive "cube" symbol in rgl, but you can get an array of
colour-coded spheres:
x <- rep(1:3, each=9)
y <- rep(rep(1:3, each=3), 3)
z <- rep(1:3, 9)
colours <- terrain.colors(27)
plot3d(x,y,z,col=colours, type="s", size=10)
If you really want cubes, you can put them together (start with cube3d()
to get one, and build on that), but it's a lot of work.
Duncan Murdoch
>
> On Fri, Feb 20, 2009 at 10:56 AM, Duncan Murdoch <murdoch at stats.uwo.ca>wrote:
>
>> On 2/20/2009 10:50 AM, kapo coulibaly wrote:
>>
>>> I have data on a regular grid in the format: x y z data. I would like to
>>> be able to plot them in 3d kind of like a volume or a mesh with colors. Is
>>> that possible in R and how?
>>>
>>
>> There are lots of ways, depending on what you want the plot to look like.
>> One is
>>
>> library(rgl)
>> plot3d(x, y, z, col=color)
>>
>> (assuming you also have a variable indicating the color to plot).
>>
>> Duncan Murdoch
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list