Gnuplot: 4d color plot using matrix format

I know that for the 4th color chart (3d surface, and the color is set by the 4th field), I can use the format data file

# XYZC 1 1 0 4 1 2 1 3 2 1 4 2 2 2 4 5 ... 

and then use

 set pm3d splot "datafile.dat" u 1:2:3:4 with pm3d 

On the other hand, I know how to make a simple surface plot where the values ​​of X and Y are implicit, while the value of Z is in matrix format:

 #Z DATA ONLY 0 1 4 4 splot "datafile.dat" matrix 

Is there a way to make 4d color graphics using this matrix format? For example, taking Z data from one file and corresponding color data from another file, or combining Z and color values ​​into one file in matrix format?

+6
source share
2 answers

If I understand the question correctly, this seems possible. See examples below.

  • http://www.gnuplotting.org/tag/matrix/

    All we need to create such a plot is the image plot style and Of course, the data must be in the correct format. Suppose a matrix representing the z-values ​​of a dimension.

     0 1 2 3 4 3 2 1 0 0 1 2 3 4 3 2 1 0 0 1 2 3 4 3 2 1 0 0 1 2 3 4 3 2 1 0 0 1 2 3 4 3 2 1 0 0 1 2 3 4 3 2 1 0 0 1 2 3 4 3 2 1 0 0 1 2 3 4 3 2 1 0 0 1 2 3 4 3 2 1 0 

    To display these values ​​in different shades of gray, we specify the appropriate palette . In addition, we apply the above mentioned image style and matrix format. As a result, shown in Figure 2.

     set palette grey plot 'color_map.dat' matrix with image 

    z values ​​with color

  • http://gnuplot.sourceforge.net/demo/heatmaps.html

     # # Two ways of generating a 2D heat map from ascii data # set title "Heat Map generated from a file containing Z values only" unset key set tic scale 0 # Color runs from white to green set palette rgbformula -7,2,-7 set cbrange [0:5] set cblabel "Score" unset cbtics set xrange [-0.5:4.5] set yrange [-0.5:4.5] set view map splot '-' matrix with image 5 4 3 1 0 2 2 0 0 1 0 0 0 1 0 0 0 0 2 3 0 1 2 4 3 e e 

    Heat map generated from a file only containing z values

+1
source

I do not think this was the original question.

I realized that he wants to draw colored spheres in three-dimensional space, so XYZ is the coordinates, and C is the color intensity. Is that the case?

0
source

Source: https://habr.com/ru/post/891658/


All Articles