Hey Monks,
I am trying to plot a 2D surface or contour plot or heat map in perl. I decided to give Chart::Gnuplot a try. I could not find any documentation or example codes for this particular case. I have my X and Y coordinates in array @x and @y. Each position (X,Y) has a corresponding value in @data. This is what I have so far. How do I plot this?
use strict;
use warnings;
use Chart::Gnuplot;
my (@x,@y,@data); #data is initialized.
my $chart = Chart::Gnuplot->new(
output => "test1.png",
title => "3D plot from arrays of x, y and z corrdinates",
xlabel => 'x',
ylabel => 'y',
);
$chart->set(view => '180,180,1,1');
my $dataSet = Chart::Gnuplot::DataSet->new(
xdata => \@x,
ydata => \@y,
zdata => \@data,
);
$chart->plot3d($dataSet);
Any help is highly appreciated. Thanks again monks!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.