my $chart = Chart::Gnuplot->new( terminal => 'windows', title => "3D plot from arrays of x, y and z coordinates", xlabel => 'x', ylabel => 'y', ); #my $x = 110; #my $y = 130; $chart->set(pm3d => 'map'); $chart->set(palette => 'defined (0 0 0 1, 1 1 1 0, 2 1 0 0)'); $chart->set(dgrid3d => '385,385'); $chart->set(cbrange => "[$x:$y]"); my $dataSet = Chart::Gnuplot::DataSet->new( points => \@array, ); my $mw = new MainWindow; my $frame = $mw->Frame->pack( -anchor => 'w' ); $frame->Button(-text => "Exit", -command => sub{&quit, $mw->destroy; })->pack(-side => "bottom"); my $plotbutton = $frame->Button( -text => 'Plot', -command => \&plot, )->pack( -side => "bottom"); $mw->protocol( 'WM_DELETE_WINDOW', \&quit ); $mw->bind( "", sub { $plotbutton->invoke } ); MainLoop; sub plot { $chart->plot3d($dataSet); } sub quit { $chart->close; $mw->destroy; }