Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Char::Plot problems

by house15 (Initiate)
on Dec 31, 2003 at 19:34 UTC ( [id://317978]=perlquestion: print w/replies, xml ) Need Help??

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

Hello, Everyone. I'm trying to get Chart::Plot to work. I don't get any errors that I can find. The data seems to be set right and appropriate bounds on the graph. I send the results string to an output file like:
open (OUT, "> plot.png"); print OUT $img->draw(); close OUT;
and everything seems to work fine, but when I try to view the results image, the viewer tells me it's not png or that it is corrupted. I opened up the png data in vim and it says PNG at the top so I'm guessing it's corrupted. Also, I used  $img->image_type() and the result is png, so my version of GD (2.11) should be supporting it. Any ideas? Thanks, House.

Replies are listed 'Best First'.
Re: Char::Plot problems
by MidLifeXis (Monsignor) on Dec 31, 2003 at 20:32 UTC

    A couple things...

    • Check the results of your open call.
    • Check the results of your print - I am guessing that draw() is bailing, and may return something
    • Make sure to use strict; use warnings;

    Good luck

    --MidLifeXis

      Thanks for your response. I've been using strict and  warnings. The open and the print are working, too as far as I can tell. Supposedly, if  draw() fails an error is set in the  Chart::Plot object, which I check for.

      In short, the script ends with no errors and the draw() function writes to the file. It just doesn't seem to be writing the right stuff.

      Obviously, I'm baffled.
Re: Char::Plot problems
by PERLscienceman (Curate) on Dec 31, 2003 at 22:40 UTC
    TRY THIS:
    open (OUT, "> plot.png"); binmode OUT; print OUT $img->draw(); close OUT;
      You, sir, are a genius. I saw that in the examples, but the comment said it was for "DOSish" systems. Since I'm a newbie and on LINUX I ignored that. Thanks for the help. House.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://317978]
Approved by sgifford
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-26 03:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found