I am trying to run this code in "R" in order to plot a density function kernel smoothing and then save the plot as an "eps" file:
library(ks)
library(rgl)
kern <- read.table(file.choose(), sep=",")
hat <- kde(kern)
plot(hat, drawpoints=TRUE, xlab = "x", ylab= "y", zlab= "z")
rgl.postscript("plot1.eps","eps",drawText=TRUE)
The problem is that when I save the plot in eps format, it just shows the plot in one color (yellow) instead of a rage of colors (yellow, orange, red...) which shows different densities... (The plot in R is fine but when I save it as eps, the color is changed) Do you know what is the problem with this code, or could you introduce me any other function that can save the plot that I generated in R as pdf or eps? (since it's an interactive RGL plot, I cannot use pdf() function. Also I tried rgl.snapshot, but every time it crashes and seems doesn't work...Following is part of my data: (x,y,z locations of points)
163.911642 248.952593 1.428709101
163.930843 249.077891 0.425459167
163.773321 249.288606 2.319076487
162.256416 246.990378 2.658388572
165.300014 247.950225 2.151660061
164.922344 249.017609 0.848590512
163.909127 248.881616 2.466267052
163.91322 249.118025 0.576787314
164.658937 249.547614 1.25279399
378.710211 132.601628 0.109772592
379.402818 132.858292 0.756297975
379.91023 132.912093 0.436653026
379.453418 132.815987 0.349591828
379.46519 132.694182 0.648543879
378.01787 132.615919 0.245000332
56.816299 27.469173 2.587220473
56.958051 27.103275 3.64182119
55.763676 26.59811 2.957732481
55.299606 26.054619 0.924209356
56.505342 27.671528 4.191381437
... ... ...
295.366938 24.360195 2.779443783
291.361501 23.21226 0.975021774
292.26276 22.053726 1.092983265
159.333055 41.087969 0.185656788
154.424175 37.83109 3.327367998
158.723404 40.487105 0.563578901
157.204282 41.678425 1.464830439