title: how to draw a filled.contour plot with a data.frame of 3 variables in R (without regular grid)?
body: <p>(Sorry if my english is not perfect... :-s)</p>
  
  <p>My question is almost the same that in this subject :
  <a href="https://stackoverflow.com/questions/12601522/creating-a-filled-contour-plot-using-data-in-lists">Creating a filled contour plot using data in lists</a></p>
  
  <p>But, the difference is that I would like to plot the density corresponding to my (x,y) coordinates, in only  1 direction !
  I explain :
  I have a data.frame like this :</p>
  
  <pre><code>X &lt;- matrix(c(1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3), nrow=4)
  Y &lt;- matrix(c(-1.0190, -0.9617, -0.9044, -0.8470, -1.0617, -0.9641, -0.8664, -0.7688,  0.4623, 0.6012,  0.7401,  0.8790), nrow=4)
  Z &lt;- matrix(c(3.9216,  3.9216,  3.9216, 11.7647,  1.9608,  1.9608,  1.9608, 11.7647,  1.9608, 1.9608,  9.8039,  9.8039), nrow=4)
  Niveau &lt;- data.frame(X=c(X),Y=c(Y),Z=c(Z))
  </code></pre>
  
  <p>X representes the x-coordinates, Y the y-coordinates and Z the density in percentage in the Y direction only. For each x-coordinate, I calculated density in the Y direction. And the result is in the Z vector.
  You can see that it is not a regular grid in (x,y).
  And I would like to plot a "contour plot" of the density Z, but so far, I didn't success...
  I tried this command :</p>
  
  <pre><code>ggplot(Niveau, aes(x=X, y=Y, z=Z)) + geom_density2d()
  </code></pre>
  
  <p>But it plots the density in the x AND y direction, and I want only in the Y direction.
  When I tried the command :</p>
  
  <pre><code>filled.contour(t(Z), nlevels=10)
  </code></pre>
  
  <p>It doesn't respect the (x,y) coordinates. And it is impossible to implement :</p>
  
  <pre><code>filled.contour(X,Y,Z, nlevels=10)
  </code></pre>
  
  <p>After, some research, i find this subject, and my probleme is the same :
  <a href="https://stackoverflow.com/questions/5847042/how-to-draw-a-contour-plot-when-data-are-not-on-a-regular-grid?rq=1">How to draw a contour plot when data are not on a regular grid?</a></p>
  
  <p>But the answer doesn't correspond : the solution is "regular grid" in (x,y), and that's not what I have !
  Somebody can help ?</p>
  
  <p>Thanks !</p>