Geht einigermaßen mit Lua.
    \begin{filecontents*}{1.dat}
    spalteB spalteA
    1   2
    3   2
    -4  15
    5   12
    -30 10
    20  1
    30  2
    5   8
    -4  3
    6   4
    7   12
    8   1
    45  9
    -3  45
    2   45
    4   23
    6   56
    -8  23  
    12  12
    56  12
    6   4
    -7  66
    76  2
    3   12
    -2  7
    4   3
    6   2
    -8  1
    -12 1
    -56 1
    -64 3
    -7  77
    -76 43
    1   34
    5   23
    7   23
    12  2
    45  2
    \end{filecontents*}
    \documentclass{article}
    \usepackage{pgfplots}
    \usepgfplotslibrary{statistics}
    \usepackage{luacode}
    \begin{luacode*}
    -- Initialize the random number generator according to
    -- http://lua-users.org/wiki/MathLibraryTutorial
    math.randomseed( tonumber(tostring(os.time()):reverse():sub(1,6)) )
    
    -- standard Box-Muller transform
    -- https://en.wikipedia.org/wiki/Box-Muller_transform
http://lua-users.org/wiki/SplitJoin
    function gauss_random(mu, sigma)
       -- State variables
string:split(sep)
       local generate = false
sep, fields = sep or ":", {}
       local z0 = 0.0
pattern = string.format("([^%s]+)", sep)
       self:gsub(pattern, function(c) fields[#fields+1] = c end)
       return fields
    end
    
    function read_table(fname)
       local z1 = 0.0
    
       -- Parameters
tab = {}
       for line in io.lines(fname) do
          local mu = mu or 0.0
_x, _y = table.unpack(line:split(' '))
          local sigma = sigma or 1.0
    
   x, y = tonumber(_x), tonumber(_y)
          if x and y then
             tab[#tab+1] = { x = x, y = y }
          end
       end
       return tab
    end
    
    function random()
          generate = not generate
    
          if (not generate) then
             return z1*sigma + mu;
          end
    
          local u1, u2
          repeat
             u1 = math.random()
             u2 = math.random()
          until ( u1 > 1e-16 )
    
          z0 = math.sqrt(-2.0 * math.log(u1)) * math.cos(2*math.pi * u2)
          z1 = math.sqrt(-2.0 * math.log(u1)) * math.sin(2*math.pi * u2)
          return z0*sigma + mu
       end
    
       return random
    end
    
    function generate(N)
       local gauss = gauss_random()
generate_table(tab)
       tex.sprint("{\r")
       tex.sprint("x y\r")
       for i = 1, N #tab do
          table[i] = { x = gauss(), y = gauss() }
       end
       return table
    end
    
    function generate_table(table)
       tex.sprint("{\r")
       tex.sprint("x y z\r")
       for i = 1, #table do
          tex.sprint(table[i].x tex.sprint(tab[i].x .. " " .. table[i].y tab[i].y .. " 0\r")
"\r")
       end
       tex.sprint("}")
    end
    
    function generate_hist(table,xmin,xmax,Nx,ymin,ymax,Ny)
generate_hist(tab,xmin,xmax,Nx,ymin,ymax,Ny)
       local xstep = (xmax - xmin) / (Nx-1)
       local ystep = (ymax - ymin) / (Ny-1)
    
       tex.sprint("{\r")
       tex.sprint("x y z\r")
       for x = xmin,xmax,xstep do
          for y = ymin,ymax,ystep do
             local bins = 0
             for i = 1,#table 1,#tab do
                if (x-xstep/2 <= table[i].x tab[i].x and table[i].x tab[i].x < x+xstep/2) and 
                   (y-ystep/2 <= table[i].y tab[i].y and table[i].y tab[i].y < y+ystep/2) then
                   bins = bins + 1
                end
             end
             tex.sprint(x .. " " .. y .. " " .. bins .. "\r")
          end
          tex.sprint("\r")
       end
       tex.sprint("}")
    
    end
    \end{luacode*}
    \newcommand\readtable[4]{%
      \directlua{tab = read_table("\luaescapestring{#1}")}
      \expandafter\pgfplotstableread\directlua{generate_hist(tab,#2,#3)}#4
    }
    \begin{document}
    \readtable{1.dat}{-100,100,10}{0,80,10}\histtable
    \begin{tikzpicture}
      \begin{axis}
        \addplot[
          matrix plot*,mesh/rows=10,mesh/cols=10,
          point meta=explicit,
          shader=faceted,colormap/cool
        ] table[meta=z] {\histtable};
        \addplot[only marks,mark=o] table {1.dat};
      \end{axis}
    \end{tikzpicture}
    \end{document}
![alt text][1]
---
Bevor ein Minimalbeispiel da war habe ich gaußverteilte Zufallszahlen geplottet.
    \documentclass{article}
    \usepackage{pgfplots}
    \usepgfplotslibrary{statistics}
    \usepackage{luacode}
    \begin{luacode*}
    -- Initialize the random number generator according to
    -- http://lua-users.org/wiki/MathLibraryTutorial
    math.randomseed( tonumber(tostring(os.time()):reverse():sub(1,6)) )
    
    -- standard Box-Muller transform
    -- https://en.wikipedia.org/wiki/Box-Muller_transform
    function gauss_random(mu, sigma)
       -- State variables
       local generate = false
       local z0 = 0.0
       local z1 = 0.0
    
       -- Parameters
       local mu = mu or 0.0
       local sigma = sigma or 1.0
    
       function random()
          generate = not generate
    
          if (not generate) then
             return z1*sigma + mu;
          end
    
          local u1, u2
          repeat
             u1 = math.random()
             u2 = math.random()
          until ( u1 > 1e-16 )
    
          z0 = math.sqrt(-2.0 * math.log(u1)) * math.cos(2*math.pi * u2)
          z1 = math.sqrt(-2.0 * math.log(u1)) * math.sin(2*math.pi * u2)
          return z0*sigma + mu
       end
    
       return random
    end
    
    function generate(N)
       tab = {}
       local gauss = gauss_random()
       for i = 1, N do
          tab[i] = { x = gauss(), y = gauss() }
       end
       return tab
    end
    
    function generate_table(tab)
       tex.sprint("{\r")
       tex.sprint("x y z\r")
       for i = 1, #tab do
          tex.sprint(tab[i].x .. " " .. tab[i].y .. " 0\r")
       end
       tex.sprint("}")
    end
    
    function generate_hist(tab,xmin,xmax,Nx,ymin,ymax,Ny)
       local xstep = (xmax - xmin) / (Nx-1)
       local ystep = (ymax - ymin) / (Ny-1)
    
       tex.sprint("{\r")
       tex.sprint("x y z\r")
       for x = xmin,xmax,xstep do
          for y = ymin,ymax,ystep do
             local bins = 0
             for i = 1,#tab do
                if (x-xstep/2 <= tab[i].x and tab[i].x < x+xstep/2) and 
                   (y-ystep/2 <= tab[i].y and tab[i].y < y+ystep/2) then
                   bins = bins + 1
                end
             end
             tex.sprint(x .. " " .. y .. " " .. bins .. "\r")
          end
          tex.sprint("\r")
       end
       tex.sprint("}")
    
    end
    \end{luacode*}
    \newcommand\generatetable[5]{%
      \directlua{tab = generate(#1)}
      \expandafter\pgfplotstableread\directlua{generate_table(tab)}#4
      \expandafter\pgfplotstableread\directlua{generate_hist(tab,#2,#3)}#5
    }
    \begin{document}
    \generatetable{400}{-4,4,10}{-4,4,10}\pointtable\histtable
    \begin{tikzpicture}
      \begin{axis}
        \addplot[
          matrix plot,mesh/rows=10,mesh/cols=10,
          point meta=explicit,
          shader=faceted,colormap/cool
        ] table[meta=z] {\histtable};
        \addplot[only marks,mark=o] table {\pointtable};
      \end{axis}
    \end{tikzpicture}
    \end{document}
![alt text][1]
text][2]
  [1]: http://texwelt.de/wissen/upfiles/test_197.png
  [2]: http://texwelt.de/wissen/upfiles/test_196.png