What did you not understand from Re^3: Plotting the data using different axes and the other responses in that other thread you started, where the answer to this question was covered in detail, with coding examples?

Update 1: Re-reading your follow on Re^2: Usage of use_axis, I see that you say "Even though, I mention 2 in use_axis to force one of the datasets to refer to the right Y axis, it is not working when the datasets are more than 3." I will work on an example with multiple (>3) datasets, with two significantly different output ranges, so it's obvious which scale each is graphed on, and will post it as another edit in a few minutes.

Update 2: sorry for the delay. This version of the code

#!/usr/bin/perl use warnings; use strict; use GD::Graph::mixed; my @data = ( ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"], [ 1, 4, 9, 16, 25, 36, 49, 64, 81], # +wants left: 0 .. 100 'x**2', [ 1, 1.4, 1.7, 2, 2.2, 2.4, 2.6, 2.8, 3], # +wants right: 0 .. 5 '~sqrt(x)' [ 99, 88, 77, 66, 55, 44, 33, 22, 11], # +wants left: 0 .. 100 '11*(10-x)', [ 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5], # +wants right: 0 .. 5 '0.5x', [ 1, 2, 3, 4, 5, 4, 3, 2, 1], # +wants right: 0 .. 5 '123454321' [ 98, 76, 54, 32, 10, '', '', '', ''], # +wants left: 0 .. 100 'descend', ); my $my_graph = new GD::Graph::mixed( ); my %opts = ( transparent => '0', x_label => 'nth', y1_label => 'big', y2_label => 'small', title => 'Using two axes', y1_max_value => 100, y2_max_value => 5, y_tick_number => 8, y_label_skip => 2, long_ticks => 1, use_axis => [1,2,1,2,2,1], # big, small, big, small, small, b +ig legend_placement => 'BR', x_labels_vertical => 1, x_label_position => 1/2, two_axes => 1, legend_marker_width => 100, l_margin => 10, b_margin => 10, r_margin => 20, t_margin => 10, show_values => 1, ); $my_graph->set(%opts); $my_graph->set_legend( 'x**2', '~sqrt(x)', '11*(10-x)', '0.5x', '12345 +4321', 'descend'); save_it($my_graph, \@data, 'out1.png'); # second graph, same as the first (except for use_axis) $opts{use_axis} = [1,2,1,1,1,1]; # big, small, big, big +<will shrink>, big<will shrink> my $second_graph = new GD::Graph::mixed( ); $second_graph->set(%opts); $second_graph->set_legend( 'x**2', '~sqrt(x)', '11*(10-x)', '0.5x', '1 +23454321', 'descend'); save_it($second_graph, \@data, 'out2.png'); sub save_it { my ($graph, $data_ref, $fname) = @_; my $gd = $graph->plot($data_ref) or die $graph->error; open(my $img, '>', $fname) or die "$fname: $!\n"; binmode $img; print {$img} $gd->png; close $img; }

Running that code, do you see how '123454321' and '0.5x' take up the bulk of the vertical height in "out1.png" and are down near the x-axis in "out2.png". That because they've properly switched from axis2 in "out1" to axis1 in "out2".

Update 3: further, if you were to change to $opts{use_axis} = [1,2,2,2,2,2];, which puts some of the "big" datasets on the "small" y axis, you will get an error ("Maximum for y3 too small at ..."), which shows that the third data set '11*(10-x)' tried to go on the small axis, where it doesn't fit.


In reply to Re: Usage of use_axis by pryrt
in thread Usage of use_axis by Sarat1729

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.