0

I have like 400 data points which are in forms of a 3-tuple. Something like this: [[1.2, 3.4, 7.8], [3.1, 2.6, 3.4], ... ]

Each row is a 3-tuple point, (x, y, z) which shows a point in 3D space.

What I want to do is drawing a contour diagram using these values in the form shown in https://en.wikipedia.org/wiki/Contour_line. I want this:https://en.wikipedia.org/wiki/Contour_line#/media/File:Contour2D.svg.

I want the third dimension (z) to be the source for contours.

I have seen some other examples on the net, but they are so confusing. They are relying on a function to draw the diagram which is not in my case. I am representing the function as a matrix.

I hope I give enough information to let you know what I am looking for.

Thanks guys.

mgNobody
  • 738
  • 7
  • 23
  • Are you looking for [`plt.contour`](http://matplotlib.org/examples/pylab_examples/contour_demo.html)? – mwaskom Nov 11 '15 at 16:07
  • I know about plt.contour. How to use it and how the Z parameter is filled up is totally confusing to me, or at least it is confusing considering my requirements. I don't have a mathematical function per say. I have points in form of (x, y, z), which I know z is a function of x and y. – mgNobody Nov 13 '15 at 00:51
  • I think it's not totally clear what your question is, because it sounds like `plt.contour` is very well suited for what you want to do. – mwaskom Nov 13 '15 at 01:28
  • When using `plt.contour`, a function is specified. It means we know this: `z = f(x, y)`. So, for each point in the plate of (x, y), there is value for z-dimension. However, for my situation, it is not correct. The Z-dimension does not have a value for every combination of x and y. – mgNobody Nov 13 '15 at 18:18
  • I guess this is answered [here](https://stackoverflow.com/questions/18764814/make-contour-of-scatter). – ImportanceOfBeingErnest Mar 14 '18 at 21:29

1 Answers1

0

You can try conrec algorithm from Paul Bourke. It's implemented in many languages and also good explained. It uses the marching cube algorithm.

Micromega
  • 12,486
  • 7
  • 35
  • 72
  • Thanks @Phpdevpad. I think it does the same thing as `plt.contour` does in Python. However, it is not implemented in python too. – mgNobody Nov 13 '15 at 18:20
  • @Millad:You can try my php implementation contour plot at codeplex:https://cntm.codeplex.com/. It is php but it uses matrices and the average of the 3 vertices. – Micromega Nov 13 '15 at 18:31