Plot a list of matrices at heights in 3d scatter plot - gnuplot

I have a file with a number of matrices separated by a newline. I can plot any one of these matrices as a heatmap as shown in http://gnuplot.sourceforge.net/demo/heatmaps.html
However, now I would like to visualize all the matrices together on the same graph by plotting each matrix at increasing values of z, where each point is a coloured dot. I am trying to achieve something similar to the following question,
Plot 3D Grid Data as Heat Map using gnuplot
but without the cubes, as dots are sufficient.
This is the data for one matrix:
7.606193E-01 -2.706752E-01 1.605924E-01 9.973101E-01 6.646065E-01 -4.177295E-01 -5.101588E-01 -5.338852E-01 -9.443505E-01 6.273689E-01 4.401633E-01 9.428387E-01 -1.783963E-01 1.702644E-01 -9.304313E-01 3.995178E-01
-1.574189E-01 -3.911715E-01 -5.581077E-01 -3.719385E-02 7.144460E-01 -3.147125E-01 4.237802E-01 6.533050E-01 5.385187E-01 8.391651E-02 -5.773817E-01 1.456075E-01 6.028832E-01 5.313966E-01 3.894490E-01 7.329324E-01
8.147309E-01 -8.286917E-01 -9.708381E-01 -6.634787E-02 8.603123E-01 8.952920E-01 6.777392E-01 4.347730E-01 -9.271995E-01 8.899992E-01 5.525438E-01 -7.496139E-01 7.592094E-01 3.412833E-01 1.220876E-01 7.281239E-01
6.915789E-01 3.365000E-01 -4.771788E-01 7.674200E-01 8.059295E-01 3.545558E-01 2.764826E-01 3.801301E-01 -6.679796E-01 1.163551E-01 -5.292152E-01 -3.500514E-01 -8.614216E-01 -8.356531E-02 -8.391827E-01 7.258298E-01
1.219247E-01 5.344889E-01 8.977039E-01 -5.708083E-01 -6.809624E-01 -5.687558E-01 3.830947E-01 9.990373E-01 -6.038938E-01 9.162573E-01 -4.214753E-01 4.186414E-01 -4.224649E-01 -9.376176E-01 -1.170071E-01 3.825447E-01
-1.046988E-01 5.206562E-01 -9.832160E-01 -6.588389E-01 6.122716E-01 2.926736E-01 -8.736564E-01 9.977460E-01 8.937872E-01 -8.719974E-02 -7.742046E-01 -9.490100E-01 6.090313E-01 8.220433E-01 7.705420E-01 5.937839E-01
8.668659E-01 -5.811435E-01 -4.980876E-01 -5.458175E-02 -1.702000E-01 -9.681295E-01 -9.898823E-01 8.014537E-01 6.852101E-01 3.412942E-01 -4.313660E-01 6.886256E-01 -8.974125E-01 8.012120E-01 7.893018E-01 -1.869330E-01
-1.168977E-01 -8.988775E-01 -2.580437E-01 -8.019403E-02 4.935626E-01 3.774684E-01 5.609375E-02 8.018482E-01 -9.803250E-01 -8.223162E-01 -7.441623E-02 7.592162E-01 -3.084599E-01 2.728176E-01 -7.114622E-01 -4.335231E-01
9.071215E-01 7.551532E-01 1.640213E-02 -2.627113E-01 -1.102158E-01 -3.576760E-02 7.584369E-02 3.586933E-01 9.412469E-01 -7.919924E-01 -7.883645E-01 -4.693788E-01 -1.549372E-01 1.823575E-01 4.206510E-01 -4.489097E-01
2.449895E-01 -4.566137E-02 5.805491E-01 3.808071E-01 4.885185E-01 9.662528E-01 -9.306209E-02 2.467101E-02 2.380986E-01 -9.053143E-01 -3.499831E-01 -4.224079E-01 -2.420047E-01 1.568254E-01 -1.696076E-01 -2.344714E-01
-1.045739E-01 -2.254802E-01 -5.760012E-01 7.194423E-01 9.792110E-01 -7.514746E-01 -1.239218E-01 -3.922474E-01 -6.499553E-01 5.908898E-01 8.695512E-01 -6.576686E-01 7.101708E-01 6.389254E-01 -3.228182E-01 3.177363E-01
-7.059239E-01 -8.482834E-01 -1.630977E-01 -9.891499E-01 -5.450270E-01 -6.303106E-01 1.596098E-01 -2.695453E-01 1.340886E-01 -3.888265E-01 -4.888381E-02 1.609239E-01 3.058087E-01 7.288026E-01 9.176123E-01 2.593470E-02
-5.400585E-01 8.222967E-01 3.648388E-01 -6.635013E-01 -4.210275E-01 -2.741717E-01 1.431661E-01 -2.184412E-01 -6.006791E-01 -9.289613E-03 2.788451E-01 -2.769694E-01 -9.857075E-01 -5.143206E-01 -1.455316E-01 9.782214E-01
-7.254217E-01 -1.668047E-01 -7.403084E-01 5.606276E-01 1.713349E-01 8.025852E-01 -9.133063E-01 -3.648469E-01 9.402033E-01 -2.317766E-01 7.771178E-01 8.427679E-01 5.951350E-02 9.725678E-01 7.514953E-01 -2.132574E-02
3.962623E-01 -8.680837E-01 -6.393657E-01 7.831294E-01 -5.947012E-02 -9.781432E-01 -8.829182E-01 -9.939770E-01 7.487056E-02 -7.578757E-01 6.196460E-01 -7.909356E-01 -1.149577E-01 -2.736676E-01 2.013560E-01 5.961972E-02
7.165400E-01 -2.371667E-01 -7.857778E-01 7.715441E-01 5.449374E-01 2.804987E-02 -1.380231E-01 -5.877602E-01 3.679530E-01 3.016719E-01 -5.242305E-01 1.064826E-01 -6.910435E-02 7.062310E-01 8.472682E-02 -9.717143E-01

I am not sure if I understood correctly, but it seems that you want each matrix as a heatmap at a fixed (arbitrary) z-value.
As mentioned on the link you posted, making a plot like that one would require (at least to my knowledge) a lot of scrambling around on gnuplot. However, you could have a rough idea by doing:
set term png
set out "tmp.png"
set view 80,30
splot "tmp" matrix u 1:2:(2):3 w p pt 5 ps 0.75 pal,\
"tmp" matrix u 1:2:(1):3 w p pt 5 ps 0.75 pal,\
"tmp" matrix u 1:2:(0):3 w p pt 5 ps 0.75 pal
Which would give you:
Not pretty, but works. You'd have to play around with the labels, tics and view parameters depending on how many matrices you have. Hope it helps!

You could splot each matrix with image:
set ztics 1
set ticslevel 0
stats "data.dat" matrix nooutput
set xrange [-0.5:STATS_size_x - 0.5]
set yrange [-0.5:STATS_size_y - 0.5]
splot for [i=1:3] "data.dat" matrix using 1:2:(i):3 with image notitle
Or, depending on your need, you can also splot ... with pm3d:
set view 70,23
set ztics 1
set ticslevel 0
set pm3d interpolate 5,5
set autoscale xfix
set autoscale yfix
splot for [i=1:3] "data.dat" matrix using 1:2:(i):3 with pm3d notitle

Related

gnuploting curve filled maps

I want to get a map using gnuplot like map1.
There are my code and part of the data.When I do set set timefmt "%Y/%m/%d/%h" set xdata time``set format x "%m/%d", it responded error in map2. I didn't know how to figure out it. Hope you can help me.
set style data lines
set style fill solid 1.00 noborder
set boxwidth 0.75 absolute
unset ylabel
unset xlabel
unset xtics
set origin 0.050, 0.300
unset ylabel
#set timefmt "%Y/%m/%d/%h"
#set xdata time
#set format x "%m/%d"
set ytics nomirror font ",11"
set style increment default
set xtics nomirror norangelimit
set ytics 0,80,320
set size 0.9,0.9
set size ratio 0.4
unset key
plot [][0:320]'average.shijiazhua.ch36km.2020.NSA_total.ts' using 1:(0):(\$2) w filledcu axis x1y1 lc rgb "#EF476F" t "Power",\
'' using 1:(\$2):(\$2+\$3) w filledcu lc rgb "#8ac926" t "Industry",\
'' using 1:(\$2+\$3):(\$2+\$3+\$4) w filledcu lc rgb "#1982c4" t "Agriculture",\
'' using 1:(\$2+\$3+\$4):(\$2+\$3+\$4+\$5) w filledcu t "Residential",\
'' using 1:(\$2+\$3+\$4+\$5):(\$2+\$3+\$4+\$5+\$6) w filledcu lc rgb "#c77dff" t "Transportation"
Data:
2020050500 34.92820 33.47148 69.01359 8.37408 36.82053
2020050501 34.14014 31.02070 68.22377 8.03866 35.97493
2020050502 32.93465 28.59794 66.69872 7.79872 34.76229
2020050503 31.56261 26.31655 64.97402 7.60045 33.42817
2020050504 29.55138 23.19680 61.65179 7.20578 31.10942
2020050505 28.45511 21.41614 60.70938 7.15501 29.97279
2020050506 28.78439 21.22073 63.38977 7.55193 30.63113
2020050507 28.32452 20.49873 64.72398 7.80252 30.85250
2020050508 25.49913 18.48231 60.84341 7.72398 29.33283
2020050509 19.03617 14.95413 49.02392 7.68153 23.93946
2020050510 14.25507 12.42948 39.15635 7.59906 19.45655
2020050511 11.56549 10.86627 33.26527 7.08790 16.58210
2020050512 10.40714 10.28374 30.64410 6.73005 15.23610
2020050513 9.99347 10.23459 30.32369 6.50979 15.00718
2020050514 9.77059 10.03319 30.06268 6.34308 14.90386
2020050515 9.46511 9.68426 28.68079 6.15453 14.22397
2020050516 9.12669 9.52622 27.02652 6.12770 13.46605
2020050517 8.94960 9.70764 26.01473 6.21285 12.75945
2020050518 8.30828 9.19368 23.64348 5.64860 11.42775
2020050519 6.98423 7.77228 19.39676 4.56069 9.39085
2020050520 5.81946 6.37644 15.79359 3.60976 7.73696
2020050521 5.36498 5.64128 14.26162 3.11704 7.00662
2020050522 5.18471 5.20392 13.71013 2.84699 6.70183
2020050523 4.96575 4.67512 13.20869 2.56693 6.34549
2020050600 4.80342 4.29339 12.99936 2.36875 6.11740
2020050601 4.57129 3.82130 12.45918 2.13018 5.80136
2020050602 4.62375 3.69038 12.84608 2.07090 5.95253
2020050603 4.89624 3.78565 13.95552 2.15729 6.42439
2020050604 5.11386 3.70182 14.69319 2.17235 6.70257
2020050605 5.32001 3.66094 15.21974 2.19411 6.86478
2020050606 5.51991 3.87873 15.74852 2.32875 7.07490
2020050607 5.67472 4.34660 16.24980 2.56207 7.47552
2020050608 7.11860 7.23675 22.40004 3.77179 10.82728
2020050609 7.91739 8.27180 24.90193 4.18627 12.04413
2020050610 8.40120 8.44643 25.63029 4.42067 12.51950
2020050611 8.78894 8.91031 26.46757 4.79258 13.22055
2020050612 8.75023 9.05808 25.82002 5.18174 13.31731
2020050613 8.69377 9.18953 25.18435 5.58854 13.35642
2020050614 8.67938 9.23050 24.79873 5.81155 13.34736
2020050615 8.61072 9.05110 24.20865 5.83554 13.13042
2020050616 8.61898 9.38255 24.24635 6.02599 13.15560
2020050617 9.88121 12.44088 28.35582 7.22637 15.13754
2020050618 13.03567 17.87587 35.27399 8.69368 18.69806
2020050619 17.21906 22.73761 41.73368 9.50554 22.38980
2020050620 22.06430 26.93686 48.36322 10.13785 26.27978
2020050621 27.02551 30.15065 54.72841 10.65425 30.01287
2020050622 29.04600 30.14368 57.09066 10.54669 31.39031
2020050623 28.72626 28.07003 56.50034 10.02480 30.99561
2020050700 28.97064 26.99266 57.29614 9.75325 31.34316
2020050701 29.37847 26.09241 57.38815 9.41128 31.39288
2020050702 29.04029 23.62373 54.13726 8.71631 29.70628
2020050703 26.91615 19.50575 47.41990 7.68835 26.01030
2020050704 22.78487 15.26919 39.35748 6.38515 21.32836
2020050705 15.26723 10.62037 27.09076 5.20689 14.57554
2020050706 8.87406 7.55900 17.58181 4.93560 9.53557
2020050707 6.11438 6.48395 14.25941 5.27410 7.86598
2020050708 4.67842 5.50418 12.43140 5.45161 7.09094
2020050709 3.64316 4.24208 10.22776 5.41426 6.11685
2020050710 3.17714 3.64387 8.92585 5.55745 5.67752
2020050711 3.20047 3.70725 8.78954 5.71015 5.83647
2020050712 3.50073 4.00986 9.26960 5.64515 6.21379
2020050713 3.59172 4.10384 9.19951 5.44214 6.23010
2020050714 3.32714 3.86352 8.31776 4.95656 5.70188
2020050715 2.92304 3.50896 7.19465 4.30262 4.96345
2020050716 2.61181 3.36959 6.41498 3.78693 4.42651
2020050717 2.77914 4.12923 6.82416 3.69544 4.57126
2020050718 4.21519 6.94777 9.53290 4.03701 6.17134
2020050719 6.95361 11.13112 14.64627 4.72538 9.09068
2020050720 10.43964 15.30013 21.20108 5.65491 12.65777
2020050721 13.85205 18.44100 27.72278 6.57799 16.04925
2020050722 16.65494 20.41442 33.30551 7.37484 18.98996
2020050723 18.98237 21.99487 38.32611 8.08933 21.69509
2020050800 21.45151 23.63957 42.98992 8.55449 24.35935
I'm not sure whether this question is fully answered.
I cleaned up your code a little. I don't know why you used \$2. If you put the below code into a text file and load this text file to gnuplot it should work.
Edit: to make the plot command a bit shorter and more clear you can:
define a function myTime(col) = timecolumn(col,myTimeFmt)
instead of filling the area between 2 curves, fill the area between a curve and the x-axis, but start with the upper curve.
why do you unset key? don't you want a legend?
Code:
### filledcurves and time data
reset session
$Data <<EOD
2020050500 34.92820 33.47148 69.01359 8.37408 36.82053
2020050501 34.14014 31.02070 68.22377 8.03866 35.97493
2020050502 32.93465 28.59794 66.69872 7.79872 34.76229
2020050503 31.56261 26.31655 64.97402 7.60045 33.42817
2020050504 29.55138 23.19680 61.65179 7.20578 31.10942
2020050505 28.45511 21.41614 60.70938 7.15501 29.97279
2020050506 28.78439 21.22073 63.38977 7.55193 30.63113
2020050507 28.32452 20.49873 64.72398 7.80252 30.85250
2020050508 25.49913 18.48231 60.84341 7.72398 29.33283
2020050509 19.03617 14.95413 49.02392 7.68153 23.93946
2020050510 14.25507 12.42948 39.15635 7.59906 19.45655
2020050511 11.56549 10.86627 33.26527 7.08790 16.58210
2020050512 10.40714 10.28374 30.64410 6.73005 15.23610
2020050513 9.99347 10.23459 30.32369 6.50979 15.00718
2020050514 9.77059 10.03319 30.06268 6.34308 14.90386
2020050515 9.46511 9.68426 28.68079 6.15453 14.22397
2020050516 9.12669 9.52622 27.02652 6.12770 13.46605
2020050517 8.94960 9.70764 26.01473 6.21285 12.75945
2020050518 8.30828 9.19368 23.64348 5.64860 11.42775
2020050519 6.98423 7.77228 19.39676 4.56069 9.39085
2020050520 5.81946 6.37644 15.79359 3.60976 7.73696
2020050521 5.36498 5.64128 14.26162 3.11704 7.00662
2020050522 5.18471 5.20392 13.71013 2.84699 6.70183
2020050523 4.96575 4.67512 13.20869 2.56693 6.34549
2020050600 4.80342 4.29339 12.99936 2.36875 6.11740
2020050601 4.57129 3.82130 12.45918 2.13018 5.80136
2020050602 4.62375 3.69038 12.84608 2.07090 5.95253
2020050603 4.89624 3.78565 13.95552 2.15729 6.42439
2020050604 5.11386 3.70182 14.69319 2.17235 6.70257
2020050605 5.32001 3.66094 15.21974 2.19411 6.86478
2020050606 5.51991 3.87873 15.74852 2.32875 7.07490
2020050607 5.67472 4.34660 16.24980 2.56207 7.47552
2020050608 7.11860 7.23675 22.40004 3.77179 10.82728
2020050609 7.91739 8.27180 24.90193 4.18627 12.04413
2020050610 8.40120 8.44643 25.63029 4.42067 12.51950
2020050611 8.78894 8.91031 26.46757 4.79258 13.22055
2020050612 8.75023 9.05808 25.82002 5.18174 13.31731
2020050613 8.69377 9.18953 25.18435 5.58854 13.35642
2020050614 8.67938 9.23050 24.79873 5.81155 13.34736
2020050615 8.61072 9.05110 24.20865 5.83554 13.13042
2020050616 8.61898 9.38255 24.24635 6.02599 13.15560
2020050617 9.88121 12.44088 28.35582 7.22637 15.13754
2020050618 13.03567 17.87587 35.27399 8.69368 18.69806
2020050619 17.21906 22.73761 41.73368 9.50554 22.38980
2020050620 22.06430 26.93686 48.36322 10.13785 26.27978
2020050621 27.02551 30.15065 54.72841 10.65425 30.01287
2020050622 29.04600 30.14368 57.09066 10.54669 31.39031
2020050623 28.72626 28.07003 56.50034 10.02480 30.99561
2020050700 28.97064 26.99266 57.29614 9.75325 31.34316
2020050701 29.37847 26.09241 57.38815 9.41128 31.39288
2020050702 29.04029 23.62373 54.13726 8.71631 29.70628
2020050703 26.91615 19.50575 47.41990 7.68835 26.01030
2020050704 22.78487 15.26919 39.35748 6.38515 21.32836
2020050705 15.26723 10.62037 27.09076 5.20689 14.57554
2020050706 8.87406 7.55900 17.58181 4.93560 9.53557
2020050707 6.11438 6.48395 14.25941 5.27410 7.86598
2020050708 4.67842 5.50418 12.43140 5.45161 7.09094
2020050709 3.64316 4.24208 10.22776 5.41426 6.11685
2020050710 3.17714 3.64387 8.92585 5.55745 5.67752
2020050711 3.20047 3.70725 8.78954 5.71015 5.83647
2020050712 3.50073 4.00986 9.26960 5.64515 6.21379
2020050713 3.59172 4.10384 9.19951 5.44214 6.23010
2020050714 3.32714 3.86352 8.31776 4.95656 5.70188
2020050715 2.92304 3.50896 7.19465 4.30262 4.96345
2020050716 2.61181 3.36959 6.41498 3.78693 4.42651
2020050717 2.77914 4.12923 6.82416 3.69544 4.57126
2020050718 4.21519 6.94777 9.53290 4.03701 6.17134
2020050719 6.95361 11.13112 14.64627 4.72538 9.09068
2020050720 10.43964 15.30013 21.20108 5.65491 12.65777
2020050721 13.85205 18.44100 27.72278 6.57799 16.04925
2020050722 16.65494 20.41442 33.30551 7.37484 18.98996
2020050723 18.98237 21.99487 38.32611 8.08933 21.69509
2020050800 21.45151 23.63957 42.98992 8.55449 24.35935
EOD
set size 0.9,0.9
set size ratio 0.4
unset xlabel
unset xtics
set xtics nomirror norangelimit
unset ylabel
set ytics nomirror font ",11"
set ytics 0,80,320
myTimeFmt = "%Y%m%d%H"
set format x "%m/%d\n%H:%M" time
set style data lines
set style fill solid 1.00 noborder
set style increment default
myTime(col) = timecolumn(col,myTimeFmt)
plot [][0:320] \
$Data u (myTime(1)):($2+$3+$4+$5+$6) w filledcu x1 lc rgb "#c77dff" t "Transportation", \
'' u (myTime(1)):($2+$3+$4+$5) w filledcu x1 t "Residential",\
'' u (myTime(1)):($2+$3+$4) w filledcu x1 lc rgb "#1982c4" t "Agriculture",\
'' u (myTime(1)):($2+$3) w filledcu x1 lc rgb "#8ac926" t "Industry",\
'' u (myTime(1)):($2) w filledcu x1 lc rgb "#EF476F" t "Power"
### end of code
Result:

Merging two loglog plot in gnuplot

given the following set of data:
0.0010339964703699645 1.1335006374746552e-7 0.0036126270484542334
0.0012221213681267867 1.9921394136413835e-7 0.005261243901795814
0.0014205289558535598 3.288567819970283e-7 0.007425886368281838
0.0017072805793891044 5.09897629791369e-7 0.010481131341546832
0.001984452250029774 8.417246932261471e-7 0.014793400915475614
0.0023455026862141174 0.000001389495494373136 0.020235896477251224
0.002772242492080673 0.0000022937401556835766 0.028561585549968214
0.003276623164863039 0.0000037864418582867756 0.04031272694269899
0.003808572703579145 0.000005870937850692427 0.05344304028586673
0.004426882588756425 0.000009691579392800477 0.07085004591866341
0.005320504478191538 0.000015026946780037802 0.09999999999999795
0.006184271765580915 0.000024806061902520164 0.13679002274643795
0.00743264474795339 0.0000435969173544848 0.20555363918508876
0.008784937113875308 0.00006759770831018738 0.2901249202026803
0.010041876641771868 0.0001115883992507748 0.3727593720314877
0.011868891598451578 0.00018420699693267163 0.5261243901795244
0.014264776540746428 0.0003040837394100148 0.7196856730011411
0.0168601041894875 0.0005019729006676898 1.0157871652296924
0.019927624696285583 0.0008286427728546826 1.4793400915475645
0.023553248637906678 0.0013679002274643991 2.0235896477251267
0.027377045003188133 0.0021209508879201926 2.768068739417809
0.03182162276758441 0.0035012061856667213 3.669660188580873
0.04674029725500457 0.012258444754550964 7.783169035335985
0.062101694189156224 0.02442053094548645 13.679002274643823
0.07158292449880059 0.04159562163071843 18.134408785428295
0.08531678524172823 0.0665471179633392 27.25047957060815
0.10083928648856323 0.10985411419875572 37.27593720314892
0.11721022975334817 0.17033053754470567 49.417133613237674
0.13623894453468574 0.28117686979742307 65.51285568595429
0.16102620275609408 0.46415888336127725 95.40954763499826
0.1935313656264482 0.7662204546142304 138.9495494373119
0.22874238366617797 1.2648552168552907 190.0691202813751
0.27035968002353816 2.222996482526191 268.2695795279694
0.31425172980765415 3.2374575428176398 366.96601885808883
0.3714265618637218 5.34430402858675 501.97290066768466
0.4390037596367272 8.822227063126444 708.5004591866399
0.5188759253192368 14.563484775012384 969.1579392800378
0.5931161449307741 23.29951810515367 1325.7113655900946
0.7248599145008832 39.68619443383435 1930.6977288832318
0.828572105824921 61.53407071116586 2559.54792269951
0.9958297992232203 101.5787165229707 3612.627048453646
1.1770106683368593 178.52567354823375 5098.976297913632
1.41460506489842 276.8068739417843 7425.88636828145
1.6170052641696395 456.9450168789167 9844.581958011371
1.9112025450223642 708.5004591866457 13051.074191219035
2.221480309984754 1169.5726687403355 17852.567354823266
2.6256555351043787 1930.6977288832436 24420.53094548635
3.1556771051918786 3187.141611585059 33404.84983513217
3.667991428805581 5428.6754393238425 45694.50168789148
4.335344299236616 8157.641691281789 66547.11796333866
5.124115079800981 14337.141946186151 91029.81779915153
6.158482110660273 23667.35144725228 136790.02274643906
7.15829244988006 39069.39937054605 199213.9413641371
8.182493376519213 56898.660290182816 272504.7957060832
9.671212897295495 99999.99999999959 384621.9041536204
I want to use gnuplot to do a log-log plot of the data using atomic units in the left y axys and using another units in the right y axys. Attemting to do so using the command:
p 'Freq_vs_Intensity_TDPT_AU.dat' u 1:2 w l, '' u 1:($2*3.51e16) w l axes x1y2
Produces two lines that are not superimposed as I want. How can I do this log-log plot?
should the rescaled column represent the same data expressed in different units, then there is probably no need to plot it twice. One could merely set the corresponding y2range and show the y2 axis, e.g.,
fac = 3.51e16
ymin = 1E-7
ymax = 1E5
set yr [ymin:ymax]
set y2r [ymin*fac:ymax*fac]
set ytics nomirror
set y2tics
p 'Freq_vs_Intensity_TDPT_AU.dat' u 1:2 w l
#, '' u 1:($2*3.51e16) w l axes x1y2

How plot graph with missing data lines?

I have data recorded in time. But some data lines are missing and gnuplot replace them with long lines in these intervals.
How can i set gnuplot to draw nothing instead of draw lines in these intervals?
PS. I don't have free cells in these lines, I dont have these lines at all.
lines:
column 1 ... col 195
13:30:20.8 0.78061899
13:30:21.8 5.969546498
13:32:19.8 17.21257881
13:32:20.8 6.922475345
If you don't want to draw a line between two points you must insert an empty line in the data file between the two point entries, so that effectively you have
13:30:20.8 0.78061899
13:30:21.8 5.969546498
13:32:19.8 17.21257881
13:32:20.8 6.922475345
This cannot be done with gnuplot directly, but you can use e.g. awk to do the processing on-the-fly:
set timefmt '%H:%M:%S'
set xdata time
filename = 'data.txt'
plot 'awk ''{split($1,d,":"); t_prev = t; t = (d[1] * 60 + d[2])*60 + d[3]; if (t_prev && (t - t_prev > 10)) print ""; print }'' '.filename with lines
Here, the gap threshold is 10 seconds.
I suppose your miss data identifier is "NaN", then you can use the following command
plot "data" using 1:($2) with linespoints
instead of
plot "data" using 1:2 with linespoints
The former one will ignore the missing data and treat it as blank line and therefore not draw a connecting line across the gap while the latter one will draw continuous, unbroken line.
Just for the records: there are later questions about the same/similar issue.
Avoid connection of points when there is empty data
How to remove line between "jumping" values, in gnuplot?
Removing vertical lines due to sudden jumps in gnuplot
However, my solutions there require transparent color, which was not available in at the time of OP's question (gnuplot 4.6.5, Feb 2014). Nevertheless, there is a solution without external tools like awk or changing the data.
First solution for gnuplot 4.6.: Instead of a transparent line you use a white line which, however, will cover the grid lines, although it will be hardly visible.
Second solution for gnuplot 4.6 is using vectors. This really interrupts the line and will work for gnuplot 5.x as well.
Data:
00:00:00 0.406406
00:00:44 0.339779
00:01:28 0.986602
00:02:13 0.17746
00:02:57 0.0580277
00:03:42 0.586614
00:04:26 0.84247
00:05:11 0.597502
00:05:55 0.0394846
00:06:40 0.369416
00:13:20 0.527109
00:13:42 0.371411
00:14:04 0.851465
00:14:26 0.980312
00:14:48 0.431391
00:15:11 0.545491
00:15:33 0.708445
00:15:55 0.861669
00:16:17 0.277122
00:16:40 0.787273
Script:
### avoid showing a line across larger time gaps
reset
FILE = "SO26510245.dat"
myFmt = "%H:%M:%S"
tGap = 60 # 60 seconds
set format x "%H:%M"
set timefmt "%H:%M:%S"
set xdata time
set ytics 0.5
set key top center noautotitle
set grid x,y
set multiplot layout 3,1
plot FILE u 1:2 w l lc rgb "red" ti "data as is"
myColor(col) = (t0=t1, t1=timecolumn(1), t1-t0>tGap ? 0xffffff : 0x0000ff)
plot t1=NaN FILE u 1:2:(myColor(1)) w l lc rgb var ti "white line"
myGap(col) = (t1-t0>tGap ? NaN : y0)
plot t1=y1=NaN FILE u (t0=t1,t1=timecolumn(1),t0):(y0=y1,y1=$2,myGap(0)):(t1-t0):(y1-y0) \
w vec lc rgb "web-green" nohead ti "with vectors"
unset multiplot
### end of script
Result: (created with gnuplot 4.6.0, from March 2012)

Plotting Heatmap on xyz data

I need to create a color-map ( heat-map) on this xyz datafile.
16.4645 -8.19898 -12.8904
-15.8086 -14.2834 8.16466
-22.1801 0.829724 -12.9072
-23.2899 -0.766454 -0.856553
-9.70407 -9.05421 18.1793
-20.7488 10.0369 6.15957
-22.0808 11.1614 -3.49831
-6.04398 -22.1432 -11.1618
-6.34688 -22.8299 7.09053
-4.06349 -12.694 -20.75
-12.3437 8.67375 -16.5742
The problem is, when I use
plot "lastframe.dat" using 1:2:3 with image t ''
I get the following error
warning: Number of pixels cannot be factored into integers matching grid. N = 60 K = 25
warning: Number of pixels cannot be factored into integers matching grid. N = 60 K = 25
Is there a way to plot using pm3d and get a color-map?
To get a color map using pm3d, try this:
set pm3d map
set dgrid3d
splot "lastframe.dat" using 1:2:3
Check out http://lowrank.net/gnuplot/plot3d-e.html for useful tips and tricks.

How to specify the start of the x-axis at 1 instead of 0

I use gnuplot to plot execution times measured on the CPU and GPU depending on the data size. So I have two files with the execution times in it. Plotting them is straight forward.
set title "CPU vs GPU"
set xlabel "Number of Particles (* 10'000)"
set ylabel "Time in Microseconds"
plot "cpuTimes.txt" title "CPU" with linespoints, \
"gpuTimes.txt" title "GPU" wit
The resulting plot can be found here: 1
I tried to use xtics however it doesn't shift the x-axis to start at 1 but just starts the ticks at 1. How can I shift the x-axis so it starts at 1 and ends at 50?
Update
Datafile cpuTimes.txt below
64780
129664
195490
266697
327871
391777
459150
517999
582959
647984
717377
790415
830869
900475
959599
1026041
1092899
1156022
1297471
1286325
1349227
1415936
1482857
1539580
1607389
1673436
1737098
1801568
1874431
1935975
2006892
2053077
2129867
2195117
2254467
2314478
2373546
2435416
2506850
2587302
2625556
2674799
2758387
2820720
2896794
2953550
3053817
3089501
3170513
3271537
xtics are only to "label" the x-axis. What you are looking for is some sort of "data manipulation". I'd suggest making use of using like so:
plot "cpuTimes.txt" u ($0+1):1 t "CPU" w lp, \
"gpuTimes.txt" u ($0+1):1 t "GPU" w lp
To make the plot end at 50 there are two ways:
You could specify the x-range with set xrange [1:50] or with
plot [1:50] "cpuTimes.txt" u ($0+1):1 t "CPU" w lp, \
"gpuTimes.txt" u ($0+1):1 t "GPU" w lp
You need to include every like so:
plot "cpuTimes.txt" u ($0+1):1 every 1::::50 t "CPU" w lp, \
"gpuTimes.txt" u ($0+1):1 every 1::::50 t "GPU" w lp
See every for documentation for further reference.
I haven't used gnuplot in awhile, but I believe you can use set xrange to adjust what is plotted.
In your case the command is:
set xrange [ 1 : 50 ]
Give an axis range in your plot command:
plot [1:50] "cpuTimes.txt"

Resources