in reply to Plot several data set on two separate axes
Also i see in GD::Graph two_axes option but it can be used only with two data sets
Not so. From the GD::Graph docs:
two_axes
Use two separate axes for the first and second data set. The first data set will be set against the left axis, the second against the right axis. If more than two data sets are being plotted, the use_axis option should be used to specify which data sets use which axis.
Note that if you use this option, that you need to use y1_label and y2_label, instead of just y_label, if you want the two axes to have different labels. The same goes for some other options starting with the letter 'y' and an underscore.
Default: 0.
use_axis
If two y-axes are in use and more than two datasets are specified, set this option to an array reference containing a value of 1 or 2 (for the left and right scales respectively) for each dataset being plotted. That is, to plot three datasets with the second on a different scale than the first and third, set this to [1,2,1]<.
Default: [1,2].
An example:
#! perl -slw use strict; use GD::Graph::lines; my @data = ( [ 1 .. 10 ], [ map{ -5 + int rand 40 } 1 .. 10 ], [ map{ -5000 + int rand 7000 } 1 .. 10 ], [ map{ -5 + int rand 40 } 1 .. 10 ], [ map{ -5000 + int rand 7000 } 1 .. 10 ], ); my $graph = GD::Graph::lines->new( 1000, 600 ); $graph->set( two_axes => 1, use_axis => [ 1,2,1,2 ], ); my $gd = $graph->plot( \@data ) or die $graph->error; open IMG, '>:raw', 'multiline.png' or die $!; print IMG $gd->png; close IMG; system 'multiline.png';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Plot several data set on two separate axes
by Sarat1729 (Sexton) on Jun 06, 2018 at 04:52 UTC | |
by BrowserUk (Patriarch) on Jun 06, 2018 at 10:55 UTC |