gnuplot: 3D plot of a matrix of data

心已入冬 提交于 2019-12-28 06:46:18

问题


How can I plot (a 3D plot) a matrix in Gnuplot having such data structure, using the first row and column as a x and y ticks (the first number of the first row is the number of columns) ?

4 0.5 0.6 0.7 0.8
1 -6.20 -6.35 -6.59 -6.02
2 -6.39 -6.52 -6.31 -6.00
3 -6.36 -6.48 -6.15 -5.90
4 -5.79 -5.91 -5.87 -5.46

回答1:


Exactly this data format can be read in with matrix nonuniform:

set view 50,20
set ticslevel 0
splot 'data.txt' matrix nonuniform with lines t ''

This generates the correct tics, like specified in the data file:




回答2:


To plot a 4D plot, using colour as the 4th dimension, you can use

splot  '1.txt' using 2:3:4:5  every ::1  palette
#  |                              |
#  |                              |
# used for 3d plots            skip the header line

Or do you want to draw a different picture, with x and y being the first column and line, and the numbers in the matrix just represinting z? Then use the following:

splot '1.txt' every ::1:1 matrix

To add some effects, you can change it to

set dgrid3d 4,4
splot '1.txt' every ::1:1 matrix with lines


来源:https://stackoverflow.com/questions/12750005/gnuplot-3d-plot-of-a-matrix-of-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!