phildog has asked for the wisdom of the Perl Monks concerning the following question:

Hello - I have a pretty PNG:

http://dodgeit.com/temp/file.png

created with this code:

my $chart = GD::Graph::lines->new(1000,480); $chart->set(x_label => "time", # no axes for pie chart x_labels_vertical => 1, x_label_skip => 50, y_label => "price", title => "misc stock", long_ticks => 0, # make a grid of all the ticks ); my $plot = $chart->plot($dataref) or die $chart->error;
I'd like to draw a horizontal reference line right at the number 11.

Any ideas? I looked through the /samples dir that came with the GD::Graph dist and didn't find anything promising and have also googled around quite a bit.

TIA -> Phil

Replies are listed 'Best First'.
Re: Drawing reference lines with GD::Graph
by clscott (Friar) on Jan 22, 2004 at 04:56 UTC

    Create a second dataset where every y value is equal to 11

    my $dataref = [ ['2004-01-08','2004-01-09','2004-01-10'], # X-values [ 10.9, 10.7, 10.8 ], # Y-value 1 [ 11,11,11 ], #Y-value 2 reference line ];
    --
    Clayton
      Very nice! thanks!

      Any idea how to also draw a vertical reference line?

        Could you be more explicit about what you mean by a vertical reference line?

        --
        Clayton
Re: Drawing reference lines with GD::Graph
by flyingmoose (Priest) on Jan 22, 2004 at 00:25 UTC
    Well, you can obviously draw straight on it with GD, but you don't know where the 11 is.

    Sounds like an excellent candidate for adding a feature to GD.pm, at least to convert from graph coordinates to screen coords. Just a thought, but clearly that's not the answer you were looking for! If you do get anything done, be sure to send the patch or suggestion in to the GD owner.

    Another option (also untested) might be to play with the graphing abilities of Term::GnuPlot which can also be used by Math::Pari. Dunno. Just throwing some ideas out there.