Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: How to add two array data into one GD plot?

by BrowserUk (Pope)
on Jul 29, 2012 at 21:41 UTC ( #984314=note: print w/ replies, xml ) Need Help??


in reply to Re^2: How to add two array data into one GD plot?
in thread How to add two array data into one GD plot?

Hm. You could just combine the two datasets into a single dataset. But that doesn't produce a very inspiring graph:

#! perl -slw use strict; use GD::Graph::bars; my @d1 = ( [ "2010/03/29 14:00:00", "2010/03/29 14:00:00", "2010/04/29 14:00: +00", "2010/04/29 14:00:00" ], [ 13, 15, 20, 21 ], ); my $g1 = GD::Graph::bars->new( 1000, 800 ); my $img1 = $g1->plot( \@d1 ); open PNG, '>:raw', "$0.png" or die $!; print PNG $img1->png; close PNG; system "$0.png";

or maybe you need to retain two datasets and just combine the labels, to give this:

#! perl -slw use strict; use GD::Graph::bars; my @d1 = ( [ "2010/03/29 14:00:00", "2010/04/29 14:00:00" ], [ 13, 15 ], [ 20, 21 ], ); my $g1 = GD::Graph::bars->new( 1000, 800 ); my $img1 = $g1->plot( \@d1 ); open PNG, '>:raw', "$0.png" or die $!; print PNG $img1->png; close PNG; system "$0.png";

.

Or maybe I've combined the values the wrong way and what you want is this

#! perl -slw use strict; use GD::Graph::bars; my @d1 = ( [ "2010/03/29 14:00:00", "2010/04/29 14:00:00" ], [ 13, 20 ], [ 15, 21 ], ); my $g1 = GD::Graph::bars->new( 1000, 800 ); my $img1 = $g1->plot( \@d1 ); open PNG, '>:raw', "$0.png" or die $!; print PNG $img1->png; close PNG; system "$0.png";

And maybe you want a gap between the two this

#! perl -slw use strict; use GD::Graph::bars; my @d1 = ( [ "2010/03/29 14:00:00", undef, "2010/04/29 14:00:00" ], [ 13, undef, 20 ], [ 15, undef, 21 ], ); my $g1 = GD::Graph::bars->new( 1000, 800 ); my $img1 = $g1->plot( \@d1 ); open PNG, '>:raw', "$0.png" or die $!; print PNG $img1->png; close PNG; system "$0.png";

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?


Comment on Re^3: How to add two array data into one GD plot?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://984314]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2014-08-21 03:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (127 votes), past polls