Dear PerlMonks

What must I do to get Chart::Gnuplot to plot two different Y variables vs X on one chart?

My two Y variables are:-
Y1 NFrogs, with values between zero and 400.
Y2 AirTemperature, with values between -10 and 25.
Variable X Time runs from 1 February to 28 April, with one value per day for NFrogs, 1 value every 20 minutes for Temperature.

So I set  yrange => [0,400], # Numbers of frogs crossing the road each evening

And  y2range => [-5,20], # Air temperatures by http://api.wunderground.com

Then with  $chart->plot2d( $Frogs, $Temperatures)
I get a graph of two variables, NFrogs and Temperatures, vs Date. But both NFrogs and Temperatures are plotted on a scale of 0 to 400.

The other way round i.e.  $chart->plot2d($Temperatures, $Frogs)
this time, NFrogs and Temperatures are both plotted on a scale of -10 to 25.

How do I get each Y variable plotted on its own scale?

http://www.gnuplot.info/faq says
(Q.) 4.7 Does gnuplot support multiple y-axes on a single plot?
(A.) Yes. You can have 2 x- and 2 y-axes per plot. The additional axes are called x2 and y2.

But I cant find an example of this at CPAN's Gnuplot Examples

RichardH

In reply to Chart::Gnuplot Frogs and Temperatures vs date by RCH

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.