0

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
David Arenburg
  • 91,361
  • 17
  • 137
  • 196
Ali
  • 1
  • 4
  • Please try to avoid [cross-posting](https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20140728/07c7f64e/attachment.pl) to multiple mailing lists (though SO does at least seem more appropriate than R-sig-geo). – Josh O'Brien Jul 28 '14 at 23:05
  • 1
    Your example is not reproducible. –  Jul 29 '14 at 03:25
  • @Pascal, Because you don't have the data (the table that is read here). The data is three columns and 50 rows containing real numbers which show the x,y,z locations of points. – Ali Jul 29 '14 at 15:33

1 Answers1

0

What I understand from your question is that the colours become different from what is displayed in X11 (assuming Linux environment) and the postscript (or eps) file.

Gnuplot colours are set for different terminal i.e. colours admissible to different terminals. So, the colours displayed in X11 (the default display term in Linux or Mac OSX) may be different in postscript.

To examine the permissible colours in a particular terminal is the Gnuplot command test. So, inside Gnuplot, the following set of command will produce a test.eps which when displayed will give you an idea what real colours you will be reproducing.

gnuplot> set term post colour eps
gnuplot> se out 'test.eps'
gnuplot> test
gnuplot> se te X11

Look at the test.eps file for true colour reproduction.

Madhurjya
  • 497
  • 5
  • 17
  • I am running this code in R environment. My problem is not the difference in color, my problem is that it doesn't show some colors when I save the plot in eps format (it just save the plot in one color) – Ali Jul 29 '14 at 15:36