in reply to Re^2: Plotting the data using different axes
in thread Plotting the data using different axes
GD::Graph says for "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].
If, as in zentara's Re: Plotting the data using different axes, your data is
, then use_axis => [1,2] will put the [3,4,14,...] on the left axis, and the [...,5,3,1,3,4,1] on the right axis. Using use_axis => [2,1] would swap them.my @data = ( ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [ 3, 4, 14, '', '', '', 7, 20, 15], [ '', '', '', 5, 3, 1, 3, 4, 1], );
If you add another row of y data,
, you would have it plot on the right axis by using use_axis => [1,2,2]: this says "put the first group of y data on axis 1, the second group on axis two, and the third group on axis two.".my @data = ( ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [ 3, 4, 14, '', '', '', 7, 20, 15], [ '', '', '', 5, 3, 1, 3, 4, 1], [ 5, 12, 24, 33, 19, 8, 6, 15, 21], );
If you add a fourth row
, you would have it plot on the left axis by using use_axis => [1,2,2,1], which says "put the first group of y data on axis 1, the second group on axis two, and the third group on axis two, and the fourth group on axis one."my @data = ( ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [ 3, 4, 14, '', '', '', 7, 20, 15], [ '', '', '', 5, 3, 1, 3, 4, 1], [ 5, 12, 24, 33, 19, 8, 6, 15, 21], [ 3, 14, 15, 9, 2, 6, 5, 3, 5], );
zentara's code may have confused you, with the commented rows, and having four elements in the use_axis array, even though only two groups of y data were uncommented... but if you had just uncommented the extra rows, you could have seen which axis they ended up on, which is why I believe zentara left those commented lines available.
edit: please use <code> tags, like <code>[ 5, 12, 24, 33, 19, 8, 6, 15, 21]</code>, so your anonymous-array examples don't get converted into links by the perlmonks rendering engine
|
|---|