9

How can I (or can I) present this gnuplot histogram:

enter image description here


in this style of 3D histogram view - in gnuplot?:

enter image description here


Using the same data and data format as in the gnuplot example in answer would be best.

B--rian
  • 5,578
  • 10
  • 38
  • 89
spinkus
  • 7,694
  • 4
  • 38
  • 62
  • That is very cumbersome to do entirely in gnuplot, see the last example at http://www.phyast.pitt.edu/%7Ezov1/gnuplot/html/bargraphs.html – Christoph Jul 24 '17 at 14:37
  • Have you looked at [these](http://ayapin-film.sakura.ne.jp/Gnuplot/pm3d.html)? – clabe45 Jul 28 '17 at 17:41
  • @Christoph the "Cuboids" method in link is pretty close. Unfortunately, very complicated a you say and example still lacks axes. The closest natively supported thing I can find in gnuplot is `impulses` or possibly `vector` style. The issue is, gnuplot still renders the bars/lines as 2d lines in 3d mode, not as surfaces, and I don't think it's possible to apply a surface texture to the lines. – spinkus Jul 30 '17 at 08:24

2 Answers2

2

The questions of the OP: How can I ...

There are a few workarounds that produce an output resembling the sample that you show. They do not have all the bells and whistles you may want for formatting, but they are approximations which look "ok".

  1. As per http://lowrank.net/gnuplot/plotpm3d-e.html#6.9 , pm3d should do the trick for what you need. See also pm3d down in this link.

  2. If shading is essential, you can try using some of this. But you should work out quite a bit.

  3. Another poor-man approximation to what you are asking for is given here.

I do not have gnuplot here to test these.

... (or can I)

It is widely documented that there is no facility for a 3D histogram plot, and anything to do a real such plot with the corresponding options (shading, spacing, back walls, perspective view, selection of point of view, etc.) requires complex user programming.

  • Thanks. Using pm3d as shown in link is cool idea but doesn't address a couple things: 1. spacing between bars, 2. consistent left,right,top bar shading. Also need to pre-process the data which should be too hard isn't ideal. – spinkus Jul 30 '17 at 08:50
  • @spinkus - Ok. Please see updated answer. Preprocessing for this use of `pm3d` doen't seem to be that hard. Could be done in a couple of hours, I guess. – sancho.s ReinstateMonicaCellio Jul 30 '17 at 11:19
1

Closest thing available in gnuplot that doesn't involve significant hackery and/or preprocessing seems to be impulses style. The help docs even suggest their use for 3d bar charts:

To use this style effectively in 3D plots, it is useful to choose thick lines (linewidth > 1). This approximates a 3D bar chart.

Here is a simple example using impulses, and matrix style data as in the linked heatmap example:

set title ''
unset key
set xyplane 0
set view 60,300,1.2
set xrange [-0.5:5]
set yrange [-0.5:5]
splot '-' matrix with impulses lw 20
0 0 0 0 0 0 
0 1 2 3 4 5 
0 2 4 6 8 10 
0 3 6 9 12 15 
0 4 8 12 16 20 
0 5 10 15 20 25
e

enter image description here

The issue is gnuplot renders the impulses as 2d pen strokes. It would be ideal if there was a way to some how apply a 3d surface effect to those lines, but I don't think there is a way, since they are just lines, not surfaces.

You can also use vectors style to achieve similar result to impulses above, but with support for "rgb variable" (AFAIK impulses doesn't support this). This allows you to change color based on z-value - but still no 3d surface. You'll have to use a different data format for vectors style (AFAIK), but it's a simpler transform from matrix style data than some other hack require:

set xyplane 0
set view 60,301,1.2
set xrange [0.5:5]
set yrange [0.5:5]
rgb(r,g,b) = 65536 * int(r) + 256 * int(g) + int(b)
splot '-' using 1:2:(0):(0):(0):3:(rgb($3*(255/25),0,0)) with vectors nohead lw 40
5 5 25
5 4 20
5 3 15
5 2 10
5 1 5
4 5 20
4 4 16
4 3 12
4 2 8
4 1 4
3 5 15
3 4 12
3 3 9
3 2 6
3 1 3
2 5 10
2 4 8
2 3 6
2 2 4
2 1 2
1 5 5
1 4 4
1 3 3
1 2 2
1 1 1
e

enter image description here

spinkus
  • 7,694
  • 4
  • 38
  • 62