Powered by Blogger.

Monday, October 27, 2008

Tag: , , , , ,

GNUPLOT - 3d plot surface

For 3d plot gnuplot use command splot.
splot sin(sqrt((x*x+y*y)))/sqrt(x*x+y*y) t "weaves"

[caption id="attachment_37" align="aligncenter" width="300" caption="Gnuplot surface wireframe"]Gnuplot surface wireframe[/caption]

We can add the style pm3d to add a gradient surface texture
splot sin(sqrt((x*x+y*y)))/sqrt(x*x+y*y) with pm3d t "weaves"

[caption id="attachment_38" align="aligncenter" width="300" caption="Gnuplot surface 3d pm3d"]Gnuplot surface 3d pm3d[/caption]

But you can see we need more resolution, then we must set more isosamples:
set isosamples 75,75

[caption id="attachment_39" align="aligncenter" width="300" caption="Gnuplot surface with pm3d and isosample 75,75"]Gnuplot surface with pm3d and isosample 75,75[/caption]

For more info go to gnuplot page

About David Millán Escrivá

David completed his studies in Universidad Politecnica de Valencia in IT with a Master's degree in artificial intelligence, computer graphics, and pattern recognition, focusing on pattern recognition and Computer Vision. David has more than 15 years of experience in IT, with more than ten years of experience in Computer Vision, computer graphics, and pattern recognition, working on different projects and start-ups, applying his knowledge of Computer Vision, optical character recognition, and augmented reality. Co-Author of two OpenCV books and reviewer of few more.

12 comments:

  1. In case you would be interested to do the same in Java easily, just try this nice library: http://code.google.com/p/jzy3d/

    Ok, that's kind of advert :)

    ReplyDelete
  2. Hi! I want to plot a surface with gnuplot but instead of having a function I have a data file with point coordinates in the two first colums and values of in the third column. Is it possible to plot the surface with my data file ?

    ReplyDelete
  3. Hi! piponazo, it's simply and it's possible.

    The file must have this format:

    x1 y1 val
    x1 y2 val
    x1 ... val
    x1 yn val

    x2 y1 val
    x2 y2 val
    x2 ... val
    x2 yn val

    ...

    xm y1 val
    xm y2 val
    xm ... val
    xm yn val

    You must keep care separating each block of x

    This is a example

    1 1 4
    1 2 3
    1 3 1
    1 4 5

    2 1 1
    2 2 4
    2 3 6
    2 4 1

    3 1 0
    3 2 2
    3 3 7
    3 4 1

    4 1 1
    4 2 5
    4 3 4
    4 4 7

    And you can plot with:

    splot 'data.dat' with lines

    or

    splot 'data.dat' with pm3d

    or any permited by gnuplot.

    ReplyDelete
  4. hi, nice article, i wanna ask something, is it possible to have splot in pm3d mode and wireframe at once in the same surface?

    if it yes, how to do that?

    thank you

    ReplyDelete
  5. Hi, you can use

    set pm3d hidden3d

    for example:

    set style line 1 lt 6 lw 3
    set pm3d hidden3d 1
    splot sin(sqrt((x*x+y*y)))/sqrt(x*x+y*y) with pm3d t "weaves"

    Regards.

    ReplyDelete
  6. Hello
    I'm a computer engineer, 33, and fan of 3d technology, nothing more to say, just thanks for this website !

    ReplyDelete
  7. hi!!
    is it possible to have an splot and an image at the same time with gnuplot?? I want to display an image and to overlay a plot.
    Thank you!

    ReplyDelete
  8. Hi!

    What if my data is such that I don't have the same number of y elements for each x value. Is there a way to produce 3d graphs with that sort of data set?

    thanks!

    ReplyDelete
  9. Hi
    Thank you for your contribution!
    It's been a big help!

    ReplyDelete
  10. Pankaj K MishraMay 9, 2013 at 8:09 PM

    gnuplot> splot 'fort.2' with pm3d
    Warning: Single isoline (scan) is not enough for a pm3d plot.
    Hint: Missing blank lines in the data file? See 'help pm3d' and FAQ.

    ReplyDelete
  11. An intriguing discussion is worth comment. There's no doubt that that you need to publish more on this issue, it may not
    be a taboo subject but generally people don't discuss such issues.

    To the next! All the best!!

    ReplyDelete
  12. Thank you, this helped me.

    ReplyDelete