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

Hello Monks,

I have successfully installed and used both Perl and Gnuplots separately. I would like to make Gnuplot graphs in Perl via the Chart::Gnuplots interface. I have saved this new module in the Perl directory of my Library, and added the path (using  use lib ~/PATH/Chart/Gnuplot.pm) to my Perl file. To note: I have also tried the path as  use lib ~/PATH/Chart and other variations. However, I repeatedly get the error  Can't locate Chart/Gnuplot.pm in @INC (you may need to install the Chart::Gnuplot module) and yet the location of Charts::Gnuplot is specifically in  @INC contains: .... What am I doing wrong?!

If anyone has any advice on how I can solve this, I would appreciate it greatly :) Thanks Monks!

Replies are listed 'Best First'.
Re: Locating Chart::Gnuplot
by hippo (Archbishop) on Feb 01, 2018 at 18:17 UTC
    I have saved this new module in the Perl directory of my Library

    That may well be insufficient. Most modules need to be properly installed. The README for Chart::Gnuplot explains the steps you will need to take. Did you follow those?

    See also A Guide to Installing Modules for an overview of installing modules.

      Hi Hippo,

      Yes, that was exactly what I needed! I was so stupid - installing Gnuplot, and Perl, but not actually installing the interface. I just assumed having Gnuplot working meant the interface should too *face palm*.

      Thank you!

Re: Locating Chart::Gnuplot
by VinsWorldcom (Prior) on Feb 01, 2018 at 17:50 UTC

    For me to get this to work, I need to use the full path and put it in quotes:

    use lib '/Users/VinsWorldcom/perl5/lib/perl5'; use Chart::Gnuplot;

    ... assuming Chart/Gnuplot.pm lives under the above directory.

Re: Locating Chart::Gnuplot
by thanos1983 (Parson) on Feb 01, 2018 at 18:27 UTC

    Hello SevenDimensions,

    Welcome to the Monastery. How did you install both Perl and Charts::Gnuplot from source? Have you tried to install through cpan?

    Form me I am running on LinuxOS Perl and I just installed the Charts::Gnuplot through cpan and it seems to be working just fine. I tested with the sample of code from the documentation:

    On your OS have you installed also gnuplot? It will be necessary alternatively you will get the error sh: 1: gnuplot: not found.

    Looking forward to your reply, BR.

    Seeking for Perl wisdom...on the process of learning...not there...yet!

      Hi Thanos1983

      Thank you very much for your response :) When I get to the line  $chart->plot2d($dataset); in your example script, I get the error  sh: convert: command not found. Did you get this issue?

      Thanks in advance!

        sh: convert: command not found

        convert is probably from ImageMagick. On Windows you can use its installer, on *NIX systems I usually find it easiest to use the system's package manager, e.g. on Debian/Ubuntu sudo apt-get install imagemagick (or sudo apt-get install graphicsmagick-imagemagick-compat).