Subject: | plotting points of different colors in GD::Graph::Cartesian |
From: Apurva Narechania
Sent: Friday, March 8, 2013 3:19 PM
Subject: plotting points of different colors in GD::Graph::Cartesian
Dear Michael Davis,
I'm using your GD::Graph::Cartesian module and have had some success,
but now I need to plot points in different colors. For example, the
colors on a list input to the script below should be red, whereas
everything else would be black. From the documentation, I can't really
see how this is done. It would be great if you could clarify this for
me!
Thanks,
Apurva Narechania
Sackler Genomics
AMNH
NYC
#!/usr/bin/perl
use strict;
use warnings;
use GD::Graph::Cartesian;
# create object for drawing the
frame
my $gdobj=GD::Graph::Cartesian->new (height=>800,
width=>800,
borderx=>5,
bordery=>5,
minx=>0,
miny=>0,
maxx=>$ARGV[1],
maxy=>$ARGV[2],
);
#$gdobj->color
("red");
#$gdobj->color
([0,0,0]);
my $blue=$gdobj->color('blue');
my $red = $gdobj->color('red');
my $highlights = {};
if ($ARGV[3]){
open (H, "$ARGV[3]");
while (my $line = <H>){
chomp $line;
$highlights->{$line} = 1;
}
close (H);
}
open (F, "$ARGV[0]");
while (my $line = <F>){
chomp $line;
my ($boid, $x, $y) = split (/\t/, $line);
($gdobj->color("red")) if (exists($highlights->{$boid}));
$gdobj->addPoint ($x => $y);
($gdobj->addString ($x => $y, $boid));# if ($boid ==
1);
# $gdobj->color
("black");
}
close (F);
print $gdobj->draw;