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

Hi folks,

I would be very grateful if someone could help me with the following query; is possible to plot a graph with a logarithmic y-axis using gnuplot via perl Chart::Gnuplot?

I started off with a simple example just to see if I could get it working, but the code seems to just ignore the logscale setting.

#!/usr/bin/perl use warnings; use Chart::Gnuplot; my $chart = Chart::Gnuplot->new( gnuplot => 'c:\gnuplot\binaries\wgnuplot.exe', output => 'testfile1.gif', terminal => "gif transparent", ); my @xy = ( [1, 10], [2, 100], [3, 1000], [4, 10000], ); my $dataSet = Chart::Gnuplot::DataSet->new( points => \@xy, style => "linespoints", "logscale x" => "0", "logscale y" => "1", ); $chart->plot2d($dataSet);

Any advice on the matter would be much appreciated.

Thank you.

  • Comment on Does 'Chart::Gnuplot ' support logarithmic axis (the gnuplot logscale setting)?
  • Download Code

Replies are listed 'Best First'.
Re: Does 'Chart::Gnuplot ' support logarithmic axis (the gnuplot logscale setting)?
by roboticus (Chancellor) on Sep 21, 2010 at 19:32 UTC

    AnnL:

    I've never used it, but the chart has a set() method, and gnuplot supports set logscale xy, so I'd guess that putting the following line before you plot your data would get the job done:

    $chart->set( logscale=>'xy' );

    ...roboticus

      Thanks roboticus, your solution worked :)