Skip Menu |

This queue is for tickets about the GD-Graph-Cartesian CPAN distribution.

Report information
The Basics
Id: 83844
Status: resolved
Worked: 1 hour (60 min)
Priority: 0/
Queue: GD-Graph-Cartesian

People
Owner: MRDVT [...] cpan.org
Requestors: MRDVT [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.08
Fixed in: (no value)



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;
On Sat Mar 09 03:00:22 2013, Apurva wrote: Show quoted text
> 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.
Apurva, I am sorry for your issue but thank you for pointing out the bug. This is the first report of this bug. I only use the explicit array color allocation so I never have the issue. $graph->addPoint($x=>$y, [128,128,128]); I've patched the package and have uploaded a new 0.09 version on CPAN. The issue was that the package was trying to allocate colors in the GD object and cache them in the GD::Graph::Cartesian object. However, the return from the GD->colorAllocate is the color index not the array reference or color name which is what is cached in the GD::Graph::Cartesian object. I have updated the architecture to lazy allocate colors at draw time not a data collection time so the issue is now moot. Thanks, Mike mrdvt92