# [Rd] one way to solve bad looking density plots in postscript

From: Michael Lachmann <lachmann_at_eva.mpg.de>
Date: Wed, 03 Aug 2011 09:25:22 +0200

Hi,

Density plots produced by gnuplot do not seem to have this problem:

```---
set pm3d map
set pm3d at b
set ticslevel 0.8
set isosample 40,40
set output "gtest.eps"
set term postscript eps color
splot [-3:3] [-3:3] x*x*exp(-x*x)*y*y*exp(-y*y)
--
But I haven't figured out why that is. Maybe someone who understands more about postscript can. Maybe it is something about the order that the rectangles are rendered? I did notice that rectangles are plotted with slightly different sizes - 50, 51, 50, 51 and so on. Is that it?

After a lot of experimentation, I found that a small change in the eps file can correct the output.
If in the eps file produced above, you change the line

/p2  { gsave bg fill grestore newpath } def

with

/p2  { bg gsave fill grestore stroke newpath } def

0.0001 setlinewidth
two lines before the next p2 - i.e. before we start plotting the rectangles of the image:
change:

/bg { 1 0 0 setrgb } def

59.04 73.44 41.47 37.15 r p2
to:
0.0001 setlinewidth

/bg { 1 0 0 setrgb } def

59.04 73.44 41.47 37.15 r p2

What this does is plot the outline of each rectangle in addition to filling it.
The page at:
http://pages.uoregon.edu/noeckel/MathematicaGraphics.html#ExportGraphics
Claims that Mathematica also has/had this problem, and how it can be solved there (sadly, I don't know enough Mathematica to understand that solution)

The output of the image would look even better if the axes were drawn AFTER the density rectangles, not before. That would cause the rectangles not to overwrite part of the lines of the axes. But that is probably a change in the image() routine, not in the postscript driver....

Thanks for listening,

Michael Lachmann

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
```
Received on Wed 03 Aug 2011 - 07:31:46 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 03 Aug 2011 - 12:50:14 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.