I may be missing the obvious here, but can't you concatenate the two arrays together?
@x_values_all = (@x_values1, @x_values2);
@y_values_all = (@y_values1, @y_values2);
Tom Melly, tom@tomandlu.co.uk
| [reply] [d/l] |
you can do this for the x-axis but not the y-axis too as then you will have only one data-set!
I have tried the following, but it seems to miss out some data-points (not sure why).
my @totalx_vals = (@x_vals1, @x_vals2);
my @graph_data = (\@totalx_vals, \@y_vals1, \@y_vals2);
| [reply] [d/l] |
I'm confused - you did try the logical thing of doing this twice - once for the 2 sets of x-vals and once for the 2 sets of y-vals?
I haven't yet used GD::Graph, but the syntax you gave seems to imply that
my @graph_data = (\@x_vals, \@y_vals)
is the expected format. So...
@x_vals = (@x_vals1, @x_vals2);
@y_vals = (@y_vals1, @y_vals2);
my @graph_data = (\@x_vals, \@y_vals);
If this isn't the solution, then you'll have to wait for someone who knows perl and/or GD::Graph better than me...
Tom Melly, tom@tomandlu.co.uk
| [reply] [d/l] [select] |
If you want to create a graph incorporating independent data sets, you might want to have a look at GD::Graph::mixed. I have not worked with it, but it seems to be what you are looking for.
Hope this helped.
CombatSquirrel.
Entropy is the tendency of everything going to hell. | [reply] |
I've plotted data sets with different y values, but they used the same array of x values. I'm not sure that you can use two sets of x values.
I have the O'Reilly book Programming Web Graphics with Perl & GNU Software. It is rather out of date because the graphing section it uses GIFgraph, which is deprecated, but there are few differences between GIFgraph and GD::Graph.
Here's what the book says for datasets:
"The data for the graph must be in a very particular form before you plot the graph. It must be assigned to an array, where the first element of the array is an anonymous list of the x axis values, and any subsequent elements are different data sets to be plotted against the y axis. A sample data array would looke like this:
@data = ( # First the time span
[ qw(1992 1993 1994 1995 1996 1997 1998) ],
# data set 1 = 1000s of people in Peoria
[ 5, 10, 8, 13, 16, 24, 32],
# data set 2 = 1000s of people in Santa Fe
[6.5, 9.2, 14.2, 12.8, 22, 31.7, 2] );"
GD::Graph::mixed is for graphing multiple data sets and making one points, one lines, etc. When I've used that though I've just had one x value array.
| [reply] [d/l] |
I mentioned the O'Reilly book Programming Web Graphics with Perl & GNU Software, which is out of date, then I ran across another node while searching perlmonks that you might be interested in. A review of the newer book Graphics Programming with Perl.
The book is by by Martien Verbruggen, author of GD::Graph.
| [reply] |