GD::Graph::boxplot - Produces PNG box and whisker graphs |
 
Boxplot - Box and Whisker Graph Module for Perl 5.
use GD::Graph::boxplot;
boxplot is a perl5 module that uses GD::Graph, GD, and Statistics::Descriptive to create and display PNG output for box and whisker graphs.
See the samples directory in the distribution.
Fill an array of arrays with the x values and array references to the data sets to be used. Make sure that every array has the same number of data sets as there are x values, otherwise GD:Graph will complain and refuse to compile the graph. For example:
$one = [210..275]; $two = [180, 190, 200, 220, 235, 245]; $three = [40, 140..150, 160..180, 250]; $four = [100..125, 136..140]; $five = [10..50, 100, 180];
@data = ( ["1st", "2nd", "3rd", "4th", "5th"], [$one, $two, $three, $four, $five ], [ [-25, 1..15], [-45, 25..45, 100], [70, 42..125], [undef], [180..250] ], # as many sets of data sets as you like );
If you don't have any data for a certain dataset, you can use undef as shown above, and GD::Graph will skip that box.
Create a new GG::Graph object by calling the new operator on the type boxplot:
$my_graph = new GD::Graph::boxplot( );
Set the graph options:
$my_graph->set( x_label => 'X Label', y_label => 'Y label', title => 'Some simple graph', upper_percent => 70, lower_percent => 35, step_const => 1.8 );
Output the graph:
$gd = $my_graph->plot( \@data );
open(IMG, '>box.png') or die $!; binmode IMG; print IMG $gd->png;
See GD::Graph documentation for methods for all GD::Graph graphs.
See GD::Graph documentation for options for all graphs.
Boxplot has axes, and has all of the options available to the other graphs with axes: bars, lines, points, linespoints and area. See the GD::Graph documentation for all of these options.
$my_graph->set( lower_percent => 20, upper_percent => 80 );
If do_stats is set to 0, the program assumes that the user has already calculated the required statistics for every box. The user must input these statistics in place of the raw data:
# data must be in this form: # $data = [mean, lowest, lower-percentile, median, upper-precentile, highest]; $one = [27, -35, 14, 29, 39, 52]; $two = [41, -140, 29, 45, 62, 125]; $three = [100, 30, 88, 95, 115, 155]; $four = [80, -100, 60, 100, 110, 195];
@data = ( ["1st", "2nd", "3rd", "4th"], [ $one, $two, $three, $four], # as many sets as you like, all with the required statistical data );
$my_graph = new GD::Graph::boxplot();
$my_graph->set( box_spacing => 35, do_stats => 0 );
Notice that if do_stats is set to 0, upper_percent and lower_percent are not used, because the user is able to input the actual value for the lower-percentile and upper-percetile. Also notice that outliers and far-out-values are not drawn, because the program does not have the data points to use. However, the lowest or highest values can be drawn as outliers or far-out-values if they fall outside of the whiskers.
Default: do_stats = 1, upper_percent = 75, lower_percent = 25.
Default: box_spacing = 10
Default: warnings = 1
Default: step_const = 1.5
Default: fov_const = 1
Default: box_fill = 1
Default: symbolc = 'dblue'
This module was designed to function in the same way as other GIFgraph graph types. It has all of the same functionality (except for mixed graphs) as the other graphs. This functionality includes how to set the colors that fill the boxes (same as Bars), change the size of the margins between the plot and the edge of the GIF, etc. Please read the GIFgraph documentation for the full set of options avaiable.
Written by: Nigel Wright. Converted by: George Fitch.
Design and Funding: Mark Landry, Client/Server Architects, Inc.
email: nwright@hmc.edu - Nigel gaf3@gaf3.com - George
Copyright (C) 1999 Nigel Wright. All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
GD::Graph::boxplot - Produces PNG box and whisker graphs |