Gnuplot Heat Map from XYZ data file - gnuplot

i'm having trouble with the plot of a heat map with gnuplot. I have this data file
0.0 40.0 778.78120008990152
0.0 50.0 821.24320411182714
0.0 60.0 857.79241694261157
0.0 70.0 890.06020449693267
0.0 80.0 919.06296578423655
0.0 90.0 945.48354694661066
0.0 100.0 969.80332391358638
0.0 110.0 992.37626201962348
0.0 120.0 1013.4707848548982
0.05 40.0 785.04802668734237
0.05 50.0 827.79005910832893
0.05 60.0 864.58649509875329
0.05 70.0 897.07636244554294
0.05 80.0 926.28161433212620
0.05 90.0 952.88868104300536
0.05 100.0 977.38301140737394
0.05 110.0 1000.1186127099754
0.05 120.0 1021.3660770787799
0.10 40.0 791.56182397211330
0.10 50.0 834.59556080405616
0.10 60.0 871.64949898510815
0.10 70.0 904.37004417201081
0.10 80.0 933.78677335142288
0.10 90.0 960.58855081404715
0.10 100.0 985.26351347238995
0.10 110.0 1008.1684300336018
0.10 120.0 1029.5754781163455
0.15 40.0 798.34055165487189
0.15 50.0 841.67824576244413
0.15 60.0 878.99958975502966
0.15 70.0 911.96168205893628
0.15 80.0 941.59893813600002
0.15 90.0 968.60362899084521
0.15 100.0 993.46744258593492
0.15 110.0 1016.5494213690502
0.15 120.0 1038.1233581496806
0.20 40.0 805.40555242206403
0.20 50.0 849.05987797369721
0.20 60.0 886.66147827497946
0.20 70.0 919.87499517151218
0.20 80.0 949.74215716287370
0.20 90.0 976.95914263993404
0.20 100.0 1002.0199820137157
0.20 110.0 1025.2868349030709
0.20 120.0 1047.0347386927497
0.25 40.0 812.77839951944816
0.25 50.0 856.76373305819050
0.25 60.0 894.65807150159071
0.25 70.0 928.13559296367407
0.25 80.0 958.24231762800366
0.25 90.0 985.68181901109608
0.25 100.0 1010.9489001030934
0.25 110.0 1034.4096229335219
0.25 120.0 1056.3396102939134
0.30 40.0 820.48532442240912
0.30 50.0 864.81721193165276
0.30 60.0 903.01793306626575
0.30 70.0 936.77143987457748
0.30 80.0 967.13070171686991
0.30 90.0 994.80260583578638
0.30 100.0 1020.2860583598051
0.30 110.0 1043.9491920105042
0.30 120.0 1066.0705495008092
0.35 40.0 828.55397604267148
0.35 50.0 873.24971731819551
0.35 60.0 911.77188280323685
0.35 70.0 945.81542098750799
0.35 80.0 976.43920139491001
0.35 90.0 1004.3551308142532
0.35 100.0 1030.0670096356569
0.35 110.0 1053.9431809276018
0.35 120.0 1076.2647985870872
and i'm using this comands for a contour line at 930
unset surface
set contour
set cntrparam levels discrete 930
set table
set out "e-nb-hierro.out"
splot "mapa-estabilidad.dat"
and then i use the following for the plot
unset table
set dgrid3d
set term pngcairo enhanced dashed color size 35cm,30cm font 'Arial, 28'
set output "Estabilidad.png"
set pm3d explicit
set pm3d map
set pm3d interpolate 0,0
set palette model RGB defined ( 1.4 'black', 1.7 'blue', 2.0 'red', 2.1 'yellow')
set xlabel "{/Symbol a} [MeV]"
set ylabel "{/:Italic Bag} [MeV/fm^3]"
set cblabel "{/:Italic {{/Symbol e}/n_B }}[MeV]"
set size square
set xrange [0.0:0.35]
set yrange [40:120]
set mxtics 2
set mytics 2
set xtics 0.0,0.05,0.35
splot "mapa-estabilidad.dat" u 1:2:3 w pm3d not, "e-nb-hierro.out" u 1:2:3 w l lt 8 lw 3 lc 'white' not
this is what i get:
and i want something like this:
for the previous image i didn't use dgrid3d and worked fine, but in this case the terminal pop's out the message that i need a grid, so i left it there. Please help

Without having fully understood why your script is not working, here is a slightly modified script which seems to get the desired result. So, the difference to your trial is:
writing the contour line into a datablock (writing to a file should also be fine)
unsetting contour and setting surface after writing to datablock
not using dgrid3d
Data: SO75041085.dat
0.0 40.0 778.78120008990152
0.0 50.0 821.24320411182714
0.0 60.0 857.79241694261157
0.0 70.0 890.06020449693267
0.0 80.0 919.06296578423655
0.0 90.0 945.48354694661066
0.0 100.0 969.80332391358638
0.0 110.0 992.37626201962348
0.0 120.0 1013.4707848548982
0.05 40.0 785.04802668734237
0.05 50.0 827.79005910832893
0.05 60.0 864.58649509875329
0.05 70.0 897.07636244554294
0.05 80.0 926.28161433212620
0.05 90.0 952.88868104300536
0.05 100.0 977.38301140737394
0.05 110.0 1000.1186127099754
0.05 120.0 1021.3660770787799
0.10 40.0 791.56182397211330
0.10 50.0 834.59556080405616
0.10 60.0 871.64949898510815
0.10 70.0 904.37004417201081
0.10 80.0 933.78677335142288
0.10 90.0 960.58855081404715
0.10 100.0 985.26351347238995
0.10 110.0 1008.1684300336018
0.10 120.0 1029.5754781163455
0.15 40.0 798.34055165487189
0.15 50.0 841.67824576244413
0.15 60.0 878.99958975502966
0.15 70.0 911.96168205893628
0.15 80.0 941.59893813600002
0.15 90.0 968.60362899084521
0.15 100.0 993.46744258593492
0.15 110.0 1016.5494213690502
0.15 120.0 1038.1233581496806
0.20 40.0 805.40555242206403
0.20 50.0 849.05987797369721
0.20 60.0 886.66147827497946
0.20 70.0 919.87499517151218
0.20 80.0 949.74215716287370
0.20 90.0 976.95914263993404
0.20 100.0 1002.0199820137157
0.20 110.0 1025.2868349030709
0.20 120.0 1047.0347386927497
0.25 40.0 812.77839951944816
0.25 50.0 856.76373305819050
0.25 60.0 894.65807150159071
0.25 70.0 928.13559296367407
0.25 80.0 958.24231762800366
0.25 90.0 985.68181901109608
0.25 100.0 1010.9489001030934
0.25 110.0 1034.4096229335219
0.25 120.0 1056.3396102939134
0.30 40.0 820.48532442240912
0.30 50.0 864.81721193165276
0.30 60.0 903.01793306626575
0.30 70.0 936.77143987457748
0.30 80.0 967.13070171686991
0.30 90.0 994.80260583578638
0.30 100.0 1020.2860583598051
0.30 110.0 1043.9491920105042
0.30 120.0 1066.0705495008092
0.35 40.0 828.55397604267148
0.35 50.0 873.24971731819551
0.35 60.0 911.77188280323685
0.35 70.0 945.81542098750799
0.35 80.0 976.43920139491001
0.35 90.0 1004.3551308142532
0.35 100.0 1030.0670096356569
0.35 110.0 1053.9431809276018
0.35 120.0 1076.2647985870872
Script:
### heatmap with contour
reset session
FILE = "SO75041085.dat"
unset surface
set contour
set cntrparam levels discrete 930
set table $Contour
splot FILE u 1:2:3
unset table
set surface
unset contour
set pm3d explicit
set pm3d map
set pm3d interpolate 0,0
set palette model RGB defined ( 1.4 'black', 1.7 'blue', 2.0 'red', 2.1 'yellow')
set xlabel "{/Symbol a} [MeV]"
set ylabel "{/:Italic Bag} [MeV/fm^3]"
set cblabel "{/:Italic {{/Symbol e}/n_B }}[MeV]"
set size square
set xrange [0.0:0.35]
set yrange [40:120]
set mxtics 2
set mytics 2
set xtics 0.0,0.05,0.35
set key noautotitle
splot FILE u 1:2:3 w pm3d, \
$Contour u 1:2:3 w l lt 8 lw 3 lc 'white' ti "930"
### end of script
Result:

Related

Heat map on Gnuplot from data file

I'm trying to generate a 2D heat map from this data file, I think the data is well organized as the following :
0.0 40.0 778.78278125477152
0.0 50.0 821.24429287113696
0.0 60.0 857.79296488547618
0.0 70.0 890.06095542158732
0.0 80.0 919.06388700600121
0.0 90.0 945.48341255862601
0.0 100.0 969.80434954392581
0.0 110.0 992.37671186761020
0.0 120.0 1013.4707149747477
0.05 40.0 785.04864919102374
0.05 50.0 827.79091606458678
0.05 60.0 864.58789436029519
0.05 70.0 897.07701069047266
0.05 80.0 926.28235753807337
0.05 90.0 952.88921361293615
0.05 100.0 977.38381162397832
0.05 110.0 1000.1186956644323
0.05 120.0 1021.3657924885772
0.10 40.0 791.56219381880612
0.10 50.0 834.59605743738416
0.10 60.0 871.64993375468521
0.10 70.0 904.36959867719099
0.10 80.0 933.78659257178356
0.10 90.0 960.58894183366590
0.10 100.0 985.26431849394919
0.10 110.0 1008.1691538800941
0.10 120.0 1029.5762691876521
0.15 40.0 798.34195708520997
0.15 50.0 841.67845253218343
0.15 60.0 878.99959021841130
0.15 70.0 911.96216498184424
0.15 80.0 941.59880756758344
0.15 90.0 968.60362475969566
0.15 100.0 993.46813275542991
0.15 110.0 1016.5504255441598
0.15 120.0 1038.1240698190288
0.20 40.0 805.40633887246452
0.20 50.0 849.06078650575785
0.20 60.0 886.66143919098226
0.20 70.0 919.87513653318490
0.20 80.0 949.74270901298996
0.20 90.0 976.95976182084962
0.20 100.0 1002.0200216289010
0.20 110.0 1025.2865573011743
0.20 120.0 1047.0349932153122
0.25 40.0 812.77820696975073
0.25 50.0 856.76498891660458
0.25 60.0 894.65789851038267
0.25 70.0 928.13609087809073
0.25 80.0 958.24365100449450
0.25 90.0 985.68264624290816
0.25 100.0 1010.9500913222986
0.25 110.0 1034.4103129303267
0.25 120.0 1056.3393347758583
0.30 40.0 820.48464481223357
0.30 50.0 864.81798335532392
0.30 60.0 903.01887516609315
0.30 70.0 936.77239583815219
0.30 80.0 967.13114999006245
0.30 90.0 994.80346504788190
0.30 100.0 1020.2873912704987
0.30 110.0 1043.9504525864115
0.30 120.0 1066.0703849020231
0.35 40.0 828.55422268229802
0.35 50.0 873.24932742561214
0.35 60.0 911.77247403032084
0.35 70.0 945.81595169717775
0.35 80.0 976.43897273583991
0.35 90.0 1004.3562269840540
0.35 100.0 1030.0677813747072
0.35 110.0 1053.9436827572483
0.35 120.0 1076.2649157912790
i want something like this
This is what I tried to make the heat map with the only contour line at 930.
My commands were the following:
unset surface
set dgrid3d
set contour
set cntrparam levels discrete 930
set table
set out "e-nb-hierro.out"
splot "mapa-estabilidad.dat"
´´´
And then, after getting out of gnuplot and opening it again, becasue otherwise didn't make the graph, I use this commands:
´´´
unset table
set term pngcairo enhanced dashed color size 35cm,30cm font 'Arial, 28'
set output "Estabilidad.png"
set pm3d explicit
set pm3d map
set pm3d interpolate 0,0
set palette model RGB defined ( 1.4 'black', 1.7 'blue', 2.0 'red', 2.1 'yellow')
set xlabel "{/Symbol a} [MeV]"
set ylabel "{/:Italic Bag} [MeV/fm^3]"
set cblabel "{/:Italic {{/Symbol e}/n_B }}[MeV]"
set size square
set xrange [0.0:0.35]
set yrange [40:120]
set mxtics 2
set mytics 2
set xtics 10,15,100
splot "mapa-estabilidad.dat" u 1:2:3 w pm3d not, "e-nb-hierro.out" u 1:2:3 w l lt 8 lw 3 lc 'white' not
After this i get the following image :
As you can see, this isn't a good contour line (930) is just and horizontal line, not following the pattern like a curved line. And the other problem is that it doesn't label the x-axis.
Please help

Support Vector Method

I have the following dataset as a small part of the big dataset.
PM2.5 is the dependent variable, while the other seven-column
represent the independent variables, AOD, BLH, RH, WS, Prec. and Temp.
I am looking to use the Support Vector Method SVM multiple regression
to find the best fit multiple variable regression equation using the python code.
I will appreciate your help a lot.
PM2.5 AOD BLH RH WS Prec Temp SLP
43.52 0.42 0.39 0.74 1.2 0.4 4.95 1.03
18.4 0.31 0.41 0.71 2.9 0.0 13.4 1.02
53.36 0.30 0.91 0.75 3.21 2.8 17.2 1.01
18.83 0.36 0.29 0.48 1.7 0.6 20.5 1.02
21.2 0.39 0.36 0.52 0.93 0.1 22.0 1.02
12.17 0.15 0.69 0.52 0.55 0.1 18.67 1.01
8.75 0.11 0.42 0.59 4.98 0.1 18.67 1.01
7.7 0.31 0.048 0.52 0.95 0.0 22.44 1.02
6.58 0.05 0.48 0.57 2.75 0.0 32.38 1.02
Data as an xls file is here
Thanks a lot in advance

Gnuplot pm3d: 'NaN value' removes all surrounding rectangles

I would like to plot a pm3d map, where data points are not equidistant on the axis.
Since the spacings for the x and y axis are identical, it is symmetrical, though.
The problem is whenever a value is "NaN", all of the four surrounding rectangles
are not plotted. In the data file below, this happens, for example, at (x,y)=(0.14,0.33) .
If the value is not 'NaN', then the four rectangles reappear.
I discovered this problem, when I tried to plot only the values >0 or <0, where the same happens.
I tried to search the documentation and the internet, but couldn't find anything on this.
Are there any solutions to this?
Plotscript:
set view map
set pm3d at b
set style data pm3d
set pm3d corners2color c1
set size ratio 1
set autoscale fix
set cbrange [-25:25]
set palette defined (-25 "blue", 0 "white", 25 "red")
set term png
set output "test.png"
splot "data.txt" u 1:2:3 notitle
set output
Data file:
0.0 0.0 1
0.0 0.08 -2
0.0 0.14 3
0.0 0.33 -4
0.0 0.46 5
0.0 0.55 5
0.08 0.0 -6
0.08 0.08 7
0.08 0.14 -8
0.08 0.33 9
0.08 0.46 -10
0.08 0.55 -10
0.14 0.0 11
0.14 0.08 -12
0.14 0.14 13
0.14 0.33 NaN
0.14 0.46 15
0.14 0.55 15
0.33 0.0 -16
0.33 0.08 17
0.33 0.14 -18
0.33 0.33 19
0.33 0.46 -20
0.33 0.55 -20
0.46 0.0 21
0.46 0.08 -22
0.46 0.14 23
0.46 0.33 -24
0.46 0.46 25
0.46 0.55 25
0.55 0.0 21
0.55 0.08 -22
0.55 0.14 23
0.55 0.33 -24
0.55 0.46 25
0.55 0.55 25
Thanks to the comment by #theozh I figured out a solution to this problem.
I adopted the script by #theozh under Plotting Heatmap with different column/line widths to the form below. This yields for the file
1 -6 11 -16 21
-2 7 -12 17 -22
3 -8 13 -18 23
-4 9 NaN 19 -24
5 -10 15 -20 25
this plot.
This is the best solution, because the data has this format anyway and the coordinates are a different file that I read in.
Plotscript:
CoordsX = "0.04 0.11 0.24 0.40 0.51"
CoordsY = "0.04 0.11 0.24 0.40 0.51"
dimX = words(CoordsX)
dimY = words(CoordsY)
dx(i) = (word(CoordsX,i)-word(CoordsX,i-1))*0.5
dy(i) = (word(CoordsY,i)-word(CoordsY,i-1))*0.5
ndx(i,j) = word(CoordsX,i) - (i-1<1 ? dx(i+1) : dx(i))
pdx(i,j) = word(CoordsX,i) + (i+1>ColCount ? dx(i) : dx(i+1))
ndy(i,j) = word(CoordsY,j) - (j-1<1 ? dy(j+1) : dy(j))
pdy(i,j) = word(CoordsY,j) + (j+1>RowCount ? dy(j) : dy(j+1))
set xrange[ndx(1,1):pdx(ColCount,1)]
set yrange[ndy(1,1):pdy(1,RowCount)]
set tic out
max = 25
set cbrange [-max:max]
set palette defined (-max "blue", 0 "white", max "red")
set term png
set output "test.png"
plot for [i=1:dim_x] file u (real(word(CoordsX,i))):1:(ndx(i,int($0))):(pdx(i,int($0))):(ndy(i,int($0+1))):(pdy(i,int($0+1))):i with boxxyerror fs solid 1.0 palette notitle
set output
### end of code

Plotting Heatmap with different column/line widths

I am simulating something and want to figure out the influence of two parameters. Therefore I vary them both and look for the result on each pair of parameter values and get a result like:
0 1000 2000 3000 4000 5000 ....
0 13.2 14.8 19.9 25.5 27.3 ...
1000 21.3 25.9 32.3 etc.
2000 etc.
3000
4000
....
To visualize them, I use gnuplot, creating a heatmap, which works perfectly fine, showing me colors and height:
reset
set terminal qt
set title "Test"
unset key
set tic scale 0
set palette rgbformula 7,5,15
set cbrange [0:100]
set cblabel "Transmission"
set pm3d at s interpolate 1,1
unset surf
set xlabel "U_{Lense} [V]"
set ylabel "E_{Start} [eV]"
set datafile separator "\t"
splot "UT500test.csv" matrix rowheaders columnheaders
Now I want to look more detailed on some areas on my heatmap, and vary my parameters in steps of 100 difference, not 1000 as shown in the table above. But because the simulation takes quite a long time, I just do this for some areas, so my table looks like this:
0 1000 2000 2100 2200 2300 2400 ... 2900 3000 4000 ...
...
Now I want to show this in the heatmap, too. But everytime I tried this, all the bins on the heatmap, no matter if 1000 or 100 difference are of the same width. But I want the ones with 100 difference to be only 1/10 of the width of the 1000 differences. Is there a possibility to do this?
The extra steps with stats are not necessary.
You can access the true coordinates directly as a nonuniform matrix:
set offset 100,100,100,100
plot $Data matrix nonuniform using 1:2:3 with points pt 5 lc palette
The missing piece is to fill in the full area rather than plotting single points. You can do this using pm3d:
set pm3d corners2color mean
set view map
splot $Data matrix nonuniform with pm3d
The colors do not match the previous plot because pm3d considers all 4 corners of each box when assigning a color. I told it to take the mean value (that's the default) but many other variants are possible. You could smooth the coloring further with set pm3d interpolate 3,3
You could do something with plotting style with boxxyerror. It's pretty straightforward, except the way to get the x-coordinates into an array which will be used later during plotting. Maybe, there are smarter solutions.
Script:
### heatmap with irregular spacing
reset session
unset key
$Data <<EOD
0.00 0.00 1000 2000 2100 2200 2300 2400 3000 4000
1000 0.75 0.75 0.43 0.34 0.61 0.74 0.66 0.97 0.58
1100 0.82 0.90 0.18 0.12 0.87 0.15 0.01 0.57 0.97
1200 0.10 0.15 0.68 0.73 0.55 0.07 0.98 0.89 0.01
1300 0.67 0.38 0.41 0.85 0.37 0.45 0.49 0.21 0.98
1400 0.76 0.53 0.68 0.09 0.22 0.40 0.59 0.33 0.08
2000 0.37 0.32 0.30 NaN 0.33 NaN 0.73 0.94 0.96
3000 0.07 0.61 0.37 0.54 0.32 0.28 0.62 0.51 0.48
4000 0.79 0.98 0.78 0.06 0.16 0.45 0.83 0.50 0.10
5000 0.49 0.95 0.29 0.59 0.55 0.88 0.29 0.47 0.93
EOD
stats $Data nooutput
BoxHalfWidth=50
# put first row into array
array ArrayX[STATS_columns]
set table $Dummy
plot for [i=1:STATS_columns] $Data u (ArrayX[i]=column(i)) every ::0::0 with table
unset table
plot for [i=2:STATS_columns] $Data u (ArrayX[i]):1:(BoxHalfWidth):(BoxHalfWidth):i every ::1 with boxxyerror fs solid 1.0 palette
### end of script
Result:
Edit:
With a little bit more effort you can as well generate a plot which covers the whole area.
In contrast to the simpler code from #Ethan, the recangles are centered on the datapoint coordinates and have the color of the actual datapoint z-value. Furthermore, the datapoint (2200,2000) is also plotted. The borders of the rectangles are halfway between matrix points. The outer rectangles have dimensions equal to the x and y distance to the next inner matrix point.
Revision: (simplified version, works for gnuplot>=5.0.1)
The following solution works for gnuplot 5.0.1, but not for 5.0.0 (haven't found out yet why).
There will be a warning: warning: matrix contains missing or undefined values which can be ignored.
I noticed that there seems to be a bug(?!) with the matrix column index, but you can fix it with:
colIdxFix(n) = (r0=r1,r1=column(-1),r0==r1?c=c+1:c=1) # fix for missing column index in a matrix
plot r1=c=0 $Data nonuniform matrix u 1:2:(colIdxFix(0)) ....
Script: (works with gnuplot>=5.0.1)
### heatmap with irregular spacing with filled area
# compatible with gnuplot>=5.0.1
reset session
$Data <<EOD
0.00 0.00 1000 2000 2100 2200 2300 2400 3000 4000
1000 0.75 0.75 0.43 0.34 0.61 0.74 0.66 0.97 0.58
1100 0.82 0.90 0.18 0.12 0.87 0.15 0.01 0.57 0.97
1200 0.10 0.15 0.68 0.73 0.55 0.07 0.98 0.89 0.01
1300 0.67 0.38 0.41 0.85 0.37 0.45 0.49 0.21 0.98
1400 0.76 0.53 0.68 0.09 0.22 0.40 0.59 0.33 0.08
2000 0.37 0.32 0.30 NaN 0.33 NaN 0.73 0.94 0.96
3000 0.07 0.61 0.37 0.54 0.32 0.28 0.62 0.51 0.48
4000 0.79 0.98 0.78 0.06 0.16 0.45 0.83 0.50 0.10
5000 0.49 0.95 0.29 0.59 0.55 0.88 0.29 0.47 0.93
EOD
# get irregular x- and y-values into string
Xs = Ys = ""
stats $Data matrix u ($1==0 ? Ys=Ys.sprintf(" %g",$3) : 0, \
$2==0 ? Xs=Xs.sprintf(" %g",$3) : 0) nooutput
# box extension d in dn (negative) and dp (positive) direction
d(vs,n0,n1) = abs(real(word(vs,n0+1))-real(word(vs,n1+1)))/2.
dn(vs,n) = (n==1 ? (n0=1,n1=2) : (n0=n,n1=n-1), -d(vs,n0,n1))
dp(vs,n) = (Ns=words(vs)-1, n>=Ns ? (n0=Ns-1,n1=Ns) : (n0=n,n1=n+1), d(vs,n0,n1))
unset key
set offset 1,1,1,1
set style fill solid 1.0
colIdxFix(n) = (r0=r1,r1=column(-1),r0==r1?c=c+1:c=1) # fix for missing column index in a matrix (bug?!)
plot r1=c=0 $Data nonuniform matrix u 1:2:($1+dn(Xs,colIdxFix(0))):($1+dp(Xs,c)): \
($2+dn(Ys,int(column(-1))+1)):($2+dp(Ys,int(column(-1))+1)):3 w boxxy palette
### end of script
Result:
Edit2: (I leave this here for gnuplot 5.0.0)
Just for fun, here is the "retro-version" for gnuplot 5.0:
gnuplot5.0 does not support arrays. Although, gnuplot5.0 supports datablocks, but apparently indexing like $Datablock[1] does not work. So, the workaround-around is to put the matrix X,Y coordinates into strings CoordsX and CoordsY and get the coordinates with word(). If there is not another limitation with string and word(), the following worked with gnuplot5.0 and gave the same result as above.
Script:
### heatmap with irregular spacing with filled area
# compatible with gnuplot 5.0
reset session
unset key
$Data <<EOD
0.00 0.00 1000 2000 2100 2200 2300 2400 3000 4000
1000 0.75 0.75 0.43 0.34 0.61 0.74 0.66 0.97 0.58
1100 0.82 0.90 0.18 0.12 0.87 0.15 0.01 0.57 0.97
1200 0.10 0.15 0.68 0.73 0.55 0.07 0.98 0.89 0.01
1300 0.67 0.38 0.41 0.85 0.37 0.45 0.49 0.21 0.98
1400 0.76 0.53 0.68 0.09 0.22 0.40 0.59 0.33 0.08
2000 0.37 0.32 0.30 NaN 0.33 NaN 0.73 0.94 0.96
3000 0.07 0.61 0.37 0.54 0.32 0.28 0.62 0.51 0.48
4000 0.79 0.98 0.78 0.06 0.16 0.45 0.83 0.50 0.10
5000 0.49 0.95 0.29 0.59 0.55 0.88 0.29 0.47 0.93
EOD
stats $Data nooutput
ColCount = int(STATS_columns-1)
RowCount = int(STATS_records-1)
# put first row and column into arrays
CoordsX = ""
set table $Dummy
set xrange[0:1] # to avoid warnings
do for [i=2:ColCount+1] {
plot $Data u (Value=column(i)) every ::0::0 with table
CoordsX = CoordsX.sprintf("%g",Value)." "
}
unset table
CoordsY = ""
set table $Dummy
do for [i=1:RowCount] {
plot $Data u (Value=$1) every ::i::i with table
CoordsY= CoordsY.sprintf("%g",Value)." "
}
unset table
dx(i) = (word(CoordsX,i)-word(CoordsX,i-1))*0.5
dy(i) = (word(CoordsY,i)-word(CoordsY,i-1))*0.5
ndx(i,j) = word(CoordsX,i) - (i-1<1 ? dx(i+1) : dx(i))
pdx(i,j) = word(CoordsX,i) + (i+1>ColCount ? dx(i) : dx(i+1))
ndy(i,j) = word(CoordsY,j) - (j-1<1 ? dy(j+1) : dy(j))
pdy(i,j) = word(CoordsY,j) + (j+1>RowCount ? dy(j) : dy(j+1))
set xrange[ndx(1,1):pdx(ColCount,1)]
set yrange[ndy(1,1):pdy(1,RowCount)]
set tic out
plot for [i=2:ColCount+1] $Data u (real(word(CoordsX,i-1))):1:(ndx(i-1,int($0))):(pdx(i-1,int($0))): \
(ndy(i-1,int($0+1))):(pdy(i-1,int($0+1))):i every ::1 with boxxyerror fs solid 1.0 palette
### end of script

gnuplot draw adjcent 3D cubic with different color

I am studing container loading algorithm. When I have loading plan, I use gnuplot to plot the plan (3D) as in attachment. As all goods are cubic, I want to plot one cubic border line by yellow, next brown, then yellow, next brown. Of course, the color could be any. My purpose is that I could see better the cubic loading plan. Currently, I could only plot with same color.
The better is that Container cubic border line is its own.
Part of my test data is at /2/
/2/
++++++container 40 feet data###########
0 0 0
12.0 0 0
12.0 2.3 0
0 2.3 0
0 0 0
0 0 0
0 0 2.5
12.0 0 2.5
12.0 2.3 2.5
0 2.3 2.5
### container 40 feet data#########
##########first cubic #############
0 0 2.5
0.0 0.0 0.0
0.64 0.0 0.0
0.64 0.66 0.0
0.0 0.66 0.0
0.0 0.0 0.0
0.0 0.0 1.93
0.64 0.0 1.93
0.64 0.66 1.93
0.0 0.66 1.93
0.0 0.0 1.93
0.64 0.0 0.0
0.64 0.0 1.93
0.64 0.66 0.0
0.64 0.66 1.93
0.0 0.66 0.0
0.0 0.66 1.93
################# Second cubic#################
0.64 0.0 0.0
1.27 0.0 0.0
1.27 0.66 0.0
0.64 0.66 0.0
0.64 0.0 0.0
0.64 0.0 1.93
1.27 0.0 1.93
1.27 0.66 1.93
0.64 0.66 1.93
0.64 0.0 1.93
1.27 0.0 0.0
1.27 0.0 1.93
1.27 0.66 0.0
1.27 0.66 1.93
0.64 0.66 0.0
0.64 0.66 1.93

Resources