2
votes

I am trying to draw a normal heatmap/image, but instead of a square for each data point have a triangle (actually two triangles so splitting the square in two, but that will be trivial once the below is solved). I started by looking at the gnuplot demos and there are some triangle examples close to what I want but not close enough.

So this is as far as I've got and now I have a couple of problems.

One can plot triangles instead of squares by entering in all the coordinates for each triangle in to the datafile. A triangle's corresponding coordinates are like this

     C
    /|
   / |
  /  |
 /   |
/____|
A    B

and these are entered in to a datafile as follows

Ax Ax Z
Bx By Z

Cx Cy Z
Cx Cy Z

therefore an example datafile with three triangles is (note two lines between each triangle)

0.6 0.6 1
1.4 0.6 1

1.4 1.4 1
1.4 1.4 1


1.6 0.6 2
2.4 0.6 2

2.4 1.4 2
2.4 1.4 2


2.6 0.6 3
3.4 0.6 3

3.4 1.4 3
3.4 1.4 3

which produces the image

like this

Two problems with this:

  1. even though the triangles are actually drawn very closely to 0.5, 1.5, 2.5 etc. I have to choose 0.4/6 for values in the datafile otherwise the triangles overlap (they are still overlapping but it is sufficient as is not visible when printed on paper); and
  2. a strange dent in the top right corner of the triangle.

So I am basically wondering about 1 (but don't mind as I am happy with the very small overlap) and want to fix 2 such that a nice triangle is plotted.

1

1 Answers

1
votes

It seems, that the postscript terminal draws an additional border for each of the pm3d polygons (don't know why). Just set a small linewidth (setting it to 0 is ignored).

Using a corrected data file (using 0.5, 1.5 and 2.5) like

0.5 0.5 1
1.5 0.5 1

1.5 1.5 1
1.5 1.5 1


1.5 0.5 2
2.5 0.5 2

2.5 1.5 2
2.5 1.5 2


2.5 0.5 3
3.5 0.5 3

3.5 1.5 3
3.5 1.5 3

and plotting it with

set pm3d map
set xrange [0:50]
set yrange [0:50]

set terminal postscript eps color
set output 'foobar.eps'
splot 'file.txt' lw 0.1

works fine:

enter image description here