Search code examples
gnuplot

Gnuplot and unstructured data is it possible


So far, I have been able to generate 2D contour plots using pm3d for a 2D structured data. However, I have got some data files that contains some flow visualisation of an unstructured grid that I am trying to plot next to the structured data. So far, I have found some links pointing to some scripts on how to generate contour plots Link, but it seems that the only way to do it is through dgrid3d, which only generates contours lines rather than the surface flow like this picture enter image description here.

I am just wondering if there is a better way to generate similar plot using gnuplot tool.

Thank you very much for the help!


Solution

  • It is not correct that dgrid3d only produces lines. It is a preprocessing step for your data, which can subsequent be plotted using any style you want.

    Here is an example using a pre-generated set of random points with Gaussian distribution. The code shown should work with gnuplot version 5.2 or newer. A slightly simpler plot command is possible in the current gnuplot version but the one shown still works also.

    set view map
    unset key
    set cbtics format ""  # no tic labels on the colorbar
    set palette cubehelix negative
    
    #
    # Generate a grid from point density of previously-generated Gaussian
    #
    set dgrid3d 50,50 gauss kdensity
    
    #
    # Make all contour lines black
    #
    set contour base
    set cntrparam levels incremental 0,200
    set cntrparam firstlinetype 101
    set for [L=101:110] linetype L linecolor "black" dashtype solid
    set style textbox opaque noborder
    
    set pm3d explicit at b
    
    #
    # Order of drawing is important.
    # First the surface, then the lines, then the labels
    #
    splot $random using 1:2:(1) with pm3d, \
          '' using 1:2:(1) with lines nosurface, \
          '' using 1:2:(1):("") with labels boxed
    

    enter image description here