ChrisR has asked for the wisdom of the Perl Monks concerning the following question:
I have been trying to make some graphs using GD::Graph::lines. I have run into a snag when trying to use multiple Y axes. I can configure the 1st axis with no problem at all. My problem is configuring the ticks for the second axis.
I have tried using attributes like y1_tick_number, y2_tick_number, etc. but get the error No attribute 'y2_tick_number'
I have tried specifying an array such as y_tick_number => [3,30] but the second element seems to get ignored.
I have searched the documentation and the web but can't seem to find an answer. The idea is to provide a different set of ticks for the second data set. I would like to have 15 ticks numbered 10, 20, 30, etc. on the right side of the graph. Any help will be greatly appreciated.
Here is a short example of my test code:#!/usr/bin/perl use strict; use GD::Graph::lines; my @data = ( ["Mar","Apr","May","Jun","Jul"], [5,2,10,6,4], [100,80,50,60,20] ); my $graph = GD::Graph::lines->new(800, 600); $graph->set( title => 'Test Graph', two_axes => 'true', use_axis => [1,2], x_label => 'Month', y1_label => 'Units', y1_max_value => 15, y1_min_value => 0, y_tick_number => [15,15], #second element get ignored y_label_skip => 0, y2_label => 'Profit', y2_max_value => 150, y2_min_value => 0, #y2_tick_number => 15, #throws error #y2_label_skip => 0 #throws error ) or die $graph->error; my $gd = $graph->plot(\@data) or die $graph->error; open(IMG, '>/var/www/html/file.gif') or die $!; binmode IMG; print IMG $gd->gif; close IMG; exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: GD::Graph and Multiple Y Axes
by zentara (Cardinal) on Sep 26, 2010 at 17:05 UTC | |
by ChrisR (Hermit) on Sep 26, 2010 at 18:57 UTC | |
by zentara (Cardinal) on Sep 27, 2010 at 11:12 UTC | |
|
Re: GD::Graph and Multiple Y Axes
by Proclus (Beadle) on Sep 27, 2010 at 13:02 UTC | |
|
Re: GD::Graph and Multiple Y Axes
by Anonymous Monk on Dec 28, 2010 at 19:55 UTC | |
|
Re: GD::Graph and Multiple Y Axes
by Anonymous Monk on Dec 28, 2010 at 19:55 UTC |