What I really need is for GD::Graph to extrapolate and not really represent where the data point should be plotted.

What do you mean by that?

  1. Do you want GD::Graph to simply omit any point outside the limits you specify?

    If so, should it connect the previous point directly to next?

  2. Or, do you want the graph drawn in full, but with any points or line sections that would go above or below the Y scale clipped?

    If so, one way to tackle this is two plot two graphs. Each with the same options, but one with null data ([[0],[0]]). You then blit (copy) that section of the full graph over the blank graph and print that.

    It's easier to demonstrate than describe:

    #! perl -slw use strict; use GD::Graph::lines; my @logConc = 1 .. 50; my @data = map{ -3 + rand( 6 ) } 1 .. 50; my @graphs = map GD::Graph::lines->new(500,300, 1), 1..2; for ( @graphs ) { $_->set( x_label => 'Logged stuff', y_label => 'Intensity', title => "Plot of stuff", line_width => 1, legend_spacing => 5, x_tick_number => 'auto', box_axis => 0, y_min_value => -2, y_max_value => 2, transparent => 0 ) or die $_->error; $_->set_legend('legend'); } ## Draw the full graph my $gd1 = $graphs[ 0 ]->plot( [ \@logConc, \@data ] ) or die $graphs[0]->error; ## Draw another with the same size and options, but null data. my $gd2 = $graphs[ 1 ]->plot([[0],[0]]); ## Copy the relevant portion of the full graph over the empty one $gd2->copy( $gd1, 0, 20, 0, 20, 500, 230 ); ## And display the latter. open PNG, '>:raw', 'junk.png'; print PNG $gd2->png(); close PNG; system 'junk.png';

    In theory, you could use just one graph by plotting an empty dataset, getting the gd object, setting the clip region and then plotting again with the real dataset. Unfortunately, the plots don't align correctly ;(


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"

In reply to Re^3: Hide plotted data that exceeds y_max_value in graph produced by GD::Graph::Lines by BrowserUk
in thread Hide plotted data that exceeds y_max_value in graph produced by GD::Graph::Lines by djodja

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.