gnuplot font problem (Perl CGI script)



I am trying to generate charts using gnuplot (in a Perl CGI script).
I am getting an error regarding fonts: "Could not find/open font when
opening font arial, using default".
gnuplot generates the image, but all the text looks bad, and text
rotations are omitted (causing unreadable text on the chart). I set
the environment variable 'GDFONTPATH' before calling gnuplot, but it
does not help at all. Anybody knows how to handle this problem?
Thanks!

I have the following Perl code in a CGI script:

# Create a stacked chart
sub CreateStackedChart
{
my ($ChartOption) = @_;
my $DataFile = $ChartOption->{DataFile};
my @Columns = @{$ChartOption->{Columns}};
# Remove the chart image if it already exists
if(-e "$ChartOption->{OutputFile}")
{
system("/tool/pandora64/bin/rm -f $ChartOption->{OutputFile}");
}
$ENV{'GDFONTPATH'} = "/usr/X11R6/lib/X11/fonts/msttcorefonts/";
open (FILE, "|/tool/pandora/.package/gnuplot-4.2.2/bin/gnuplot -
persist");
print FILE &GetCommonGPFileHeader($ChartOption);
print FILE <<EOC
set key invert reverse Left outside
set key autotitle columnheader
unset xtics
set xtics nomirror rotate by -90
set grid y
set border 3
set style data histograms
set style histogram rowstacked
set style fill solid border -1
set boxwidth 0.75
EOC
;
print FILE "plot '$DataFile' ";
my $Count=0;
my @PrintColumns=();
foreach my $Column (@Columns)
{
if(++$Count==1)
{
push(@PrintColumns, "using $Column:xtic(1)");
}
else
{
push(@PrintColumns, "'' using $Column");
}
}
print FILE join(', ',@PrintColumns);
close(FILE);
# Now wait until the file is created.
my $i = 0;
while (!-e "$ChartOption->{OutputFile}") {
sleep(1);
++$i;
die "Timed out waiting for gnuplot to render graph" if
($i == 5);
}
return $ChartOption->{OutputFile};
}

# Common chart options to be written to gnuplot run file
sub GetCommonGPFileHeader
{
my ($ChartOption) = @_;
my $FontSize = $ChartOption->{FontSize};
my $ChartWidth = $ChartOption->{ChartWidth};
my $ChartHeight = $ChartOption->{ChartHeight};
my $OutputFile = $ChartOption->{OutputFile};
my $ChartTitle = $ChartOption->{ChartTitle};
my $YLabel = $ChartOption->{YLabel};
my $Y2Label = $ChartOption->{Y2Label};
my $Str = "set terminal png transparent nocrop font arial $FontSize
size $ChartWidth, $ChartHeight\n";
$Str .= "set termoption noenhanced\n";
$Str .= "set title '$ChartTitle'\n";
$Str .= "set output '$OutputFile'\n";
$Str .= "set ylabel '$YLabel'\n";
$Str .= "set y2label '$Y2Label'\n";
return $Str;
}
.



Relevant Pages

  • Re: gnuplot features
    ... something like a chart. ... Everything that gnuplot produces is a chart by that definition. ... While pie charts are common in business and journalism, ... In Stevens' power ...
    (comp.graphics.apps.gnuplot)
  • fix time xtics to nonfix start point
    ... I need to create an chart with gnuplot for a datetime-data ... The data stream is for the last X hours ...
    (comp.graphics.apps.gnuplot)
  • Linear regression for time series with Gnuplot
    ... I am a big fan of Gnuplot and I used it all along my studies for ... Lately I wanted to use Gnuplot to chart some time series like weight ... Therefor I scale the x-axis like ...
    (comp.graphics.apps.gnuplot)
  • Re: Assigning Credit
    ... You *need* wgnuplot to work with pgnuplot. ... On my backup computer I removed every trace of Gnuplot, all files, ... When it was supposed to draw a chart the screen flashed and nothing ...
    (comp.graphics.apps.gnuplot)