Gnuplot:使用splot以正确的深度顺序绘制三维块

Gnuplot:使用splot以正确的深度顺序绘制三维块,gnuplot,Gnuplot,我将扩展到任意大小的绘图块 这是我的密码: reset set terminal qt size 700,524 enhanced font 'Verdana,10' # color definitions set cbrange [1:10] set style fill transparent solid 1.0 set palette defined (\ 1 '#ff4c4d',\ 2 '#ce4c7d',\ 3 '#ae559e',\ 4 '#df866d',\ 5 '#ffb66

我将扩展到任意大小的绘图块

这是我的密码:

reset

set terminal qt size 700,524 enhanced font 'Verdana,10'

# color definitions
set cbrange [1:10]
set style fill transparent solid 1.0
set palette defined (\
1 '#ff4c4d',\
2 '#ce4c7d',\
3 '#ae559e',\
4 '#df866d',\
5 '#ffb66d',\
6 '#ffe7cf',\
7 '#cecece',\
8 '#6d6d6d',\
9 '#4c4c8e',\
10 '#4c4cef')
set style line  1 lc rgb '#ff2727' lt 1 lw 0.5
set style line  2 lc rgb '#b90046' lt 1 lw 0.5
set style line  3 lc rgb '#8b0b74' lt 1 lw 0.5
set style line  4 lc rgb '#d1512e' lt 1 lw 0.5
set style line  5 lc rgb '#ff972f' lt 1 lw 0.5
set style line  6 lc rgb '#ffddba' lt 1 lw 0.5
set style line  7 lc rgb '#b9b9b9' lt 1 lw 0.5
set style line  8 lc rgb '#2e2e2e' lt 1 lw 0.5
set style line  9 lc rgb '#00005d' lt 1 lw 0.5
set style line 10 lc rgb '#0000e8' lt 1 lw 0.5

unset key
unset border
unset tics
unset colorbox
set view equal xyz

# load block function
load 'block.fct'

set pm3d hidden3d
set pm3d implicit
unset hidden3d

set lmargin 2
set rmargin 0
set bmargin 0
set tmargin 0
# get block positions from file
add_block(x,y,z,h,l,w,c) = sprintf('block(%f,%f,%f,%f,%f,%f,%i) w l ls %i,',x,y,z,h,l,w,c,c)
CMD = ''
stats 'proofblocks3.txt' u 1:(CMD = CMD.add_block($1,$2,$3,$4,$5,$6,$7)) nooutput
set xrange [0:4]
set yrange [0:4]
set zrange [0:3]
CMD = 'splot '.CMD.'1/0 w l ls 2'
# plot block
eval(CMD)
block.fct的内容:

# gnuplot function to create a cube
#
# Usage: block(x, y, z, w, l, h, c)
block(x,y,z,w,l,h,c) = sprintf('<echo "\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\
%f %f %f %i\n\n"',\
0.1+x,0.1+y,0.1+z,c,\
0.1+x,0.1+y,(h-0.1)+z,c,\
0.1+x,(l-0.1)+y,(h-0.1)+z,c,\
0.1+x,(l-0.1)+y,0.1+z,c,\
0.1+x,0.1+y,0.1+z,c,\
(w-0.1)+x,0.1+y,0.1+z,c,\
(w-0.1)+x,0.1+y,h-0.1+z,c,\
(w-0.1)+x,(l-0.1)+y,h-0.1+z,c,\
(w-0.1)+x,(l-0.1)+y,0.1+z,c,\
(w-0.1)+x,0.1+y,0.1+z,c,\
0.1+x,0.1+y,0.1+z,c,\
(w-0.1+x),0.1+y,0.1+z,c,\
(w-0.1+x),(l-0.1)+y,0.1+z,c,\
0.1+x,(l-0.1+y),0.1+z,c,\
0.1+x,0.1+y,0.1+z,c,\
0.1+x,0.1+y,(h-0.1+z),c,\
(w-0.1)+x,0.1+y,(h-0.1+z),c,\
(w-0.1)+x,(l-0.1)+y,(h-0.1+z),c,\
0.1+x,(l-0.1)+y,(h-0.1+z),c,\
0.1+x,0.1+y,(h-0.1)+z,c\
)
有没有办法解决这个问题?例如,曲面是否按正确的深度顺序绘制

没有

Gnuplot是一个具有一些模拟3D功能的2D绘图程序

事实上,其他2D绘图程序(如python的matplotlib)也存在同样的问题


< P>为了创建真实的3D绘图,我们应该考虑Python的Matlab(粗体)或Mayavi(参见:):

,你也可以给出<代码>校对块的内容吗?同时,请尝试设置pm3d depthorder,参见Hi@Christoph上的第二个示例,我已经发布了'proofblocks3.txt'的内容。不幸的是,“depthorder”并没有改变情节。请注意,我更正了主脚本,将“set unhidden3d”更正为“unset hidden3d”。谢谢好啊我不知道你怎么能让它和gnuplot一起工作。仅使用
set hidden3d
和no
pm3d
设置,它就可以工作,但无法获得颜色;)我读过,
set pm3d hidden3d
只在非常特殊的情况下有效。这就是gnuplot达到极限的地方。
# x y z w l h color
0   0   0   1   1   1   1
1   0   0   1   3   1   2
2   0   0   1   1   1   3
0   1   0   1   1   1   4
2   1   0   1   1   1   5
0   2   0   1   1   1   6
2   2   0   1   1   1   7