I've never had any luck using xdata, ydata, zdata for 3D plots; I can't work out what's supposed to be in each array, and the documentation isn't helpful.

For 3D plots, I always use points instead - you may have to munge the data in Perl a bit first, but at least it works. The following is an example based on the 'Valley of the Gnu' data in the Gnuplot manual:

use strict; use warnings; use Chart::Gnuplot; my (@x,@y,@data); #data is initialized. @data = ( [0, 0, 10], [0, 1, 10], [0, 2, 10], [1, 0, 10], [1, 1, 5], [1, 2, 10], [2, 0, 10], [2, 1, 1], [2, 2, 10], [3, 0, 10], [3, 1, 0], [3, 2, 10], ); my $chart = Chart::Gnuplot->new( output => "test1.png", title => "3D plot from arrays of x, y and z coordinates", xlabel => 'x', ylabel => 'y', ); #$chart->set(view => (180,180,1,1'); + my $dataSet = Chart::Gnuplot::DataSet->new( points => \@data, ); $chart->plot3d($dataSet);

Where the 3 element array refs are [xcoord, ycoord, zcoord] and the x's are fixed while you iterate through the y's


In reply to Re: 2d contour plot using Chart::Gnuplot by Myrddin Wyllt
in thread 2d contour plot using Chart::Gnuplot by Ppeoc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.