Search code examples
gnuplot

Contour plot other than contour lines with gnuplot


I have generated the contour plot with my data Data to plot. The output looks like contour lines. I am now trying to fill the contour plot with colors. There is a previous post about it http://gnuplot-tricks.blogspot.com/2009/07/maps-contour-plots-with-labels.html and I have followed the instructions and modified as:

 set xrange [0:32]
 set yrange [0:32]
 set table 'test.dat'
 splot "contour.dat"
 unset table

 set contour base
 set cntrparam level incremental 0, 0.1, 1
 unset surface
 set table 'cont.dat'
 splot "contour.dat"
 unset table

 reset
 set xrange [0:32]
 set yrange [0:32]
 unset key
 set palette rgbformulae 33,13,10
 p 'test.dat' with image, 'cont.dat' w l lt -1 lw 1.5 

But my plot has this appearance after new code. The gnuplot shows the warning and the output message is

 warning: Cannot contour non grid data. Please use "set dgrid3d".
 warning: Skipping data file with no valid points

I have set it there but still the appearance does not change.

Now the question is which option or command is missing or should be used to get the colored filled contour map? I am also checking the book https://www.manning.com/books/gnuplot-in-action-second-edition but still could not find the commands for that kind of plot.

The data is

0.9999      0.982523158 0.891048477 0.583411178 0.235163401 0.040130025 1.00E-05    1.00E-05    1.00E-05    0.035682725 0.005428697 0.020932041 0.029782838 0.022353315 0.01152723  1.00E-05    0.002663218 0.004234385 0.004785793 0.00412414  1.00E-05    1.00E-05    0.000580796 0.025190766 0.19110765  0.507916237 0.821045769 0.976541983 0.979832098 0.9999      0.944161278 0.720159779
0.9999      0.973067478 0.824509858 0.515498258 0.196714659 0.02215662  0.001930433 0.031876894 0.033140536 0.029554456 1.00E-05    0.007143897 0.001566911 1.00E-05    0.037378856 0.005977127 0.013283047 0.022265608 0.01827373  0.007627014 0.000167961 0.035911698 0.036163972 0.007598274 0.102779682 0.342304319 0.629002943 0.835660968 0.915237217 0.902408744 0.785948515 0.542827623
0.851954648 0.800884814 0.615992685 0.342731798 0.104482546 0.011840285 0.029469663 1.00E-05    1.00E-05    1.00E-05    1.00E-05    1.00E-05    0.026375308 1.00E-05    0.02072085  0.074807389 0.138750288 0.16703943  0.139979059 0.076340868 0.018197414 0.002778291 1.00E-05    0.001484506 0.029011079 0.156574172 0.354646905 0.536402725 0.63287085  0.618777015 0.493896783 0.291684717
0.51718903  0.466202811 0.319405608 0.140714994 0.025865626 0.036049337 1.00E-05    1.00E-05    0.03219016  0.033409853 0.033651765 0.03030058  0.031169542 0.021333766 0.129627995 0.296292679 0.435977458 0.487461936 0.428265336 0.281984362 0.118289641 0.018805742 0.003774484 0.034996285 0.00425743  0.035138289 0.120141077 0.217615538 0.277655039 0.264475233 0.185260535 0.084939547
0.182475138 0.154880431 0.086665517 0.024041383 0.005459017 1.00E-05    0.000300364 0.043848781 0.044965735 0.007238176 0.005801704 1.00E-05    0.007316639 0.101489626 0.33036401  0.593649916 0.775870253 0.830501755 0.762936865 0.563999169 0.294543097 0.083684955 0.006607316 0.003366544 1.00E-05    0.003892168 0.016420963 0.037723106 0.052984926 0.044641457 0.024308647 0.046347832
0.027792756 0.020341271 0.014089586 0.009340287 0.04140216  0.040595247 0.005715897 0.011470496 0.01468797  0.016993293 0.018003174 0.009720034 0.028838961 0.197733013 0.51363769  0.817260396 0.96815601  0.998483647 0.958424324 0.78195343  0.462313354 0.163142698 0.0210613   1.00E-05    0.002384908 0.004043211 0.004081986 0.001265788 0.000120176 0.033084563 0.030668279 1.00E-05
0.007059003 0.003655667 0.011870197 0.009394357 0.005385329 0.039035408 0.006462258 0.011999697 0.019544602 0.016464843 0.012776067 0.007972404 0.045957337 0.247832319 0.599513951 0.899196477 0.984366576 0.9999      0.977961991 0.862585385 0.541393207 0.205948244 0.033390224 0.004231    0.004866654 0.003014723 0.003623085 0.00187932  1.00E-05    1.00E-05    1.00E-05    1.00E-05
0.008747924 0.006830015 0.014403608 0.025626224 0.023730515 0.016681035 0.010401817 0.014135891 0.009650236 0.011045515 0.011609941 0.008865041 0.04281916  0.224693147 0.556126845 0.862259058 0.988832111 0.9999      0.980062911 0.820917478 0.498814169 0.184628171 0.028344465 0.003697355 0.0037474   0.003280804 0.003662558 0.002633438 0.000490997 0.00246968  0.02823553  0.031421351
0.015944971 0.04531812  0.109587044 0.175429872 0.199666866 0.165080497 0.094843153 0.03467632  0.01092787  0.010232922 0.011397636 0.009907805 0.026496074 0.144796819 0.401124894 0.68543129  0.862253462 0.906029432 0.840654843 0.641230414 0.352902499 0.114138909 0.014896994 0.003670062 0.003785455 0.0035948   0.006942384 0.019376903 0.037414369 0.042572183 0.027487039 0.008993108
0.061420875 0.191851435 0.367956007 0.505609288 0.550796197 0.485835936 0.330221357 0.153196235 0.041624218 0.010933452 0.009038844 0.008733224 0.012950915 0.060160921 0.201838898 0.399528134 0.554915502 0.604065512 0.53346247  0.365595104 0.170839767 0.042062655 0.005800244 0.003327563 0.00371733  0.009738636 0.050356042 0.13523019  0.220692933 0.253781775 0.212002473 0.121937801
0.169124299 0.423804661 0.681681444 0.835285937 0.872513269 0.810127664 0.619175791 0.342977126 0.114793875 0.020826769 0.008997988 0.00962584  0.00943097  0.017205879 0.059803286 0.143893602 0.225014755 0.252902045 0.211994667 0.125540339 0.04501628  0.009148389 0.004495928 0.004163555 0.006661964 0.048835929 0.186616289 0.383676092 0.545001152 0.605108418 0.544221317 0.37670716
0.294097103 0.629055541 0.893594948 0.988618721 0.976685668 0.972155199 0.822312358 0.51187419  0.198799352 0.037843722 0.009223186 0.010018614 0.010570771 0.009817808 0.013077596 0.026364956 0.043959741 0.049992095 0.037978171 0.018742963 0.007249969 0.00437049  0.003896394 0.003916297 0.018225634 0.128715806 0.377101189 0.661694419 0.848356881 0.903221361 0.848593119 0.659519323
0.364028753 0.725043955 0.963516567 0.9999      0.9999      0.9999      0.890867525 0.585373413 0.240701881 0.048712789 0.009715081 0.010337255 0.011821464 0.010977836 0.00884407  0.007384053 0.006941438 0.00630658  0.005438564 0.004515368 0.004670137 0.004842314 0.004975833 0.005249804 0.035841033 0.206825734 0.529812898 0.842482465 0.985394709 0.9999      0.986103824 0.843048755
0.341698481 0.690877008 0.936292264 0.979587411 0.986559237 0.987414747 0.84947266  0.539185146 0.214414917 0.041205841 0.008496801 0.009374307 0.011055057 0.010613996 0.008663892 0.006742032 0.005496349 0.004621427 0.00435038  0.004308883 0.004898404 0.00492433  0.005048379 0.005700701 0.043520492 0.234012464 0.579704002 0.889983604 0.982379619 0.993375828 0.982781739 0.89211904
0.238943568 0.531411789 0.790156262 0.918891468 0.941393619 0.874936334 0.679764686 0.388636278 0.1358585   0.022754611 0.007026365 0.008177227 0.008829201 0.008601284 0.009976017 0.015894554 0.023338217 0.024192646 0.016927589 0.008711167 0.005387796 0.005012774 0.005178965 0.005622369 0.033675965 0.194301997 0.507994163 0.822325851 0.975621338 0.9999      0.977153793 0.827093899
0.112917671 0.298927953 0.505044977 0.642557395 0.670211274 0.583949224 0.40398185  0.196169759 0.054057823 0.009466147 0.006148842 0.006808958 0.007174796 0.012870056 0.042540005 0.100975644 0.154931158 0.167143595 0.129137136 0.066511122 0.020342182 0.006284195 0.005217972 0.005392434 0.017571215 0.112878898 0.341161939 0.617612625 0.808785254 0.868113712 0.812688852 0.625567763
0.031596957 0.103478148 0.207591289 0.289162543 0.305371931 0.248806895 0.147621325 0.055623683 0.01277838  0.005999178 0.006314731 0.006303963 0.010407127 0.051789151 0.171390509 0.334244042 0.458275824 0.485704194 0.405401061 0.251352012 0.100110162 0.0213025   0.006278242 0.005891383 0.00872238  0.041567658 0.155426681 0.331548597 0.484359485 0.544393063 0.490187745 0.340368577
0.009812002 0.019350284 0.042311949 0.065272806 0.068471713 0.048752552 0.022908803 0.008573715 0.005643325 0.006265362 0.006482173 0.006727634 0.027518127 0.145281122 0.382692454 0.639072376 0.798863426 0.830046382 0.73635766  0.518132334 0.252706067 0.06932794  0.011587493 0.00680223  0.007289484 0.01172333  0.039397147 0.103830088 0.175189631 0.207447811 0.180088402 0.109516953
0.009142008 0.007468396 0.007092918 0.007194917 0.006352574 0.005314441 0.003463252 0.004980697 0.005780664 0.006724703 0.006673399 0.008850412 0.056529771 0.251919418 0.575369384 0.859645057 0.981858001 0.992720926 0.944934992 0.737904644 0.408497772 0.13349894  0.021532254 0.007498621 0.007829857 0.007292342 0.007970426 0.014446539 0.026377013 0.033924747 0.028655555 0.016063671
0.009493354 0.007487699 0.005673333 0.004660324 0.00410047  0.004871314 0.003964493 0.005073033 0.005668034 0.006521753 0.00601545  0.010009445 0.074928356 0.310027303 0.666725517 0.937368096 0.9999      0.994075034 0.997317166 0.833284025 0.490142335 0.170819653 0.027049691 0.007033414 0.007243675 0.006857442 0.005502501 0.004526947 0.004108371 0.004971427 0.004848677 0.004889328
0.007876022 0.006759912 0.00717937  0.013239625 0.02415985  0.030297081 0.024833195 0.014292012 0.007466304 0.005779199 0.005200008 0.008393379 0.066215712 0.288317689 0.63517724  0.910783797 0.9999      0.987502098 0.984117087 0.804978751 0.463714893 0.155928261 0.021877568 0.005602731 0.005886427 0.005694104 0.0048815   0.004930487 0.004682147 0.004231205 0.004275928 0.004735956
0.0056793   0.008717832 0.033348695 0.096245107 0.166988358 0.198265982 0.17100119  0.103037934 0.038559206 0.009199286 0.004414635 0.005169448 0.037380451 0.198670276 0.489754512 0.770027554 0.919724201 0.947441887 0.871499536 0.64989922  0.340568055 0.098821795 0.01130737  0.003546481 0.004720721 0.006154507 0.013063447 0.025169988 0.032513034 0.027053789 0.014876871 0.006805564
0.005399518 0.030665082 0.137397993 0.313426284 0.470733052 0.534556922 0.480739225 0.331841001 0.155967149 0.038968056 0.00604349  0.003938463 0.012501117 0.09051998  0.278185529 0.502917711 0.658355235 0.692251425 0.596928407 0.397805696 0.176612808 0.038222911 0.005033068 0.003540855 0.006838166 0.03257234  0.097642868 0.170883475 0.205429948 0.179651017 0.109581227 0.040729673
0.010464047 0.089392697 0.307689736 0.590817085 0.796078093 0.862947293 0.808781019 0.620181093 0.344097408 0.112806071 0.01465626  0.002951788 0.004174869 0.021620514 0.096433613 0.215857934 0.314494191 0.33739347  0.273552637 0.157177284 0.053251193 0.008725909 0.004293321 0.004695077 0.032790735 0.144589045 0.321823591 0.478307255 0.543087315 0.492276934 0.344165668 0.16477652
0.019903551 0.15586652  0.458005252 0.789344524 0.967306644 0.9999      0.97586068  0.825635027 0.512459492 0.19670971  0.032322867 0.004688928 0.004948534 0.004908328 0.015300786 0.04536029  0.078977855 0.088160206 0.065496559 0.030520343 0.009138938 0.004058564 0.003786815 0.013334218 0.10349762  0.328317459 0.606110839 0.803233578 0.868191128 0.816455176 0.631927813 0.356714499
0.025474633 0.182659314 0.513715197 0.847785132 0.975608287 0.9999      0.983450071 0.891000838 0.582872094 0.236365621 0.041208205 0.000293117 0.000691955 0.001940839 0.00495226  0.006267567 0.008984487 0.010145872 0.00841063  0.006030428 0.005042839 0.004840027 0.004990931 0.030782825 0.185129712 0.493278876 0.810826754 0.972668377 0.9999      0.978793074 0.831697921 0.521932075
0.01930045  0.151675481 0.449921653 0.780316009 0.962401217 0.9999      0.979257323 0.836538188 0.526192992 0.203425154 0.028384391 1.00E-05    1.00E-05    1.00E-05    0.00222998  0.004214155 0.00414953  0.004464453 0.004975862 0.005636715 0.005668266 0.005625953 0.006310905 0.042400725 0.224412221 0.562846833 0.878147251 0.980618598 0.994282176 0.982958967 0.89205072  0.585705686
0.009393489 0.082953937 0.294570816 0.574926233 0.784437523 0.859967111 0.816787759 0.636957337 0.35987384  0.115559502 0.010361086 0.031627737 0.028754766 1.00E-05    1.00E-05    0.0035418   0.005415645 0.005011286 0.005139752 0.005820283 0.006035461 0.00591033  0.006297403 0.035844481 0.196864775 0.509806148 0.825292285 0.979173578 0.9999      0.980606861 0.834718733 0.525124046
0.004053607 0.024501591 0.123408952 0.295250339 0.455955234 0.5293671   0.485136725 0.33970497  0.15744634  0.032398427 1.00E-05    1.00E-05    0.031507764 0.028527143 1.00E-05    0.001117528 0.005264872 0.004990459 0.005081482 0.005428315 0.005760736 0.005683794 0.005443788 0.018715894 0.119613748 0.35466468  0.634547526 0.82482734  0.882181273 0.826773867 0.640614453 0.362533937
0.002655957 0.006026136 0.023219304 0.080905349 0.151642055 0.186936612 0.164375467 0.097117732 0.031109035 0.004470864 0.038065762 1.00E-05    1.00E-05    0.035845328 0.006838627 0.026699524 0.039303163 0.031707646 0.017428789 0.007706403 0.005259594 0.004961271 0.004695013 0.007083378 0.043203893 0.167342754 0.352999366 0.50892877  0.567034911 0.508447251 0.353338273 0.166522149
0.005188791 0.003646668 0.000647874 0.007495457 0.014312906 0.023370868 0.019349891 0.015909783 0.013297987 0.004716524 0.042342679 0.039783293 0.003423272 0.03421355  0.106497288 0.187641421 0.220157719 0.190241303 0.117970241 0.045979037 0.010652597 0.00457506  0.004287649 0.004229215 0.008504538 0.040953111 0.113491551 0.18752673  0.217295922 0.184450903 0.105884292 0.031660304
0.004479522 0.004410448 0.007302065 0.004126552 1.00E-05    0.035801097 0.008699818 0.011939786 0.013714012 0.009248864 0.002560286 0.038098888 0.037908848 0.164841406 0.353482222 0.502417768 0.557273044 0.503049358 0.358246216 0.179673059 0.050754213 0.00738319  0.003720885 0.003715687 0.003478652 0.005359569 0.008438204 0.018563383 0.024121383 0.018956877 0.009237453 1.00E-05

Solution

  • I may have misunderstood the request... Were you asking for a smoothed contour plot where the pm3d colors correspond to discrete contour ranges?

    set view map
    set xrange [*:*] noextend
    set yrange [*:*] noextend
    set pm3d interpolate 9,9
    set palette maxcolors 10
    set palette rgbformulae 33,13,10
    
    splot 'matrix.dat' matrix with pm3d notitle
    

    enter image description here

    It's hard to get smooth contour edges when the matrix resolution is only 32x32. It's maybe a bit better if you back off to only 5 contour levels:

    enter image description here