--- loncom/xml/lonplot.pm	2002/04/24 21:24:40	1.67
+++ loncom/xml/lonplot.pm	2002/04/25 21:33:52	1.73
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Dynamic plot
 #
-# $Id: lonplot.pm,v 1.67 2002/04/24 21:24:40 matthew Exp $
+# $Id: lonplot.pm,v 1.73 2002/04/25 21:33:52 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -484,23 +484,22 @@ sub end_gnuplot {
 	## Determine filename
 	my $tmpdir = '/home/httpd/perl/tmp/';
 	my $filename = $ENV{'user.name'}.'_'.$ENV{'user.domain'}.
-	    '_'.time.'_'.$$.$randnumber.'_plot.data';
+	    '_'.time.'_'.$$.$randnumber.'_plot';
 	## Write the plot description to the file
 	&write_gnuplot_file($tmpdir,$filename,$target);
 	$filename = &Apache::lonnet::escape($filename);
 	## return image tag for the plot
 	if ($target eq 'web') {
 	    $result .= <<"ENDIMAGE";
-<img src    = "/cgi-bin/plot.gif?file=$filename&output=gif" 
+<img src    = "/cgi-bin/plot.gif?file=$filename.data&output=gif" 
      width  = "$plot{'width'}"
      height = "$plot{'height'}"
      align  = "$plot{'align'}"
      alt    = "$plot{'alttag'}" />
 ENDIMAGE
         } elsif ($target eq 'tex') {
-	    &Apache::lonnet::ssi('cgi-bin/plot.gif?file=$filename'.
-				 '&output=eps');
-	    $result = "$filename.eps";
+	    &Apache::lonnet::ssi("/cgi-bin/plot.gif?file=$filename.data&output=eps");
+	    $result = '\graphicspath{{/home/httpd/perl/tmp/}}\fbox{\includegraphics{'.&Apache::lonnet::unescape($filename).'.eps}}';
 	}
     } elsif ($target eq 'edit') {
 	$result.=&Apache::edit::tag_end($target,$token);
@@ -992,7 +991,8 @@ sub write_gnuplot_file {
 	$gnuplot_input .= "set output\n";
     } elsif ($target eq 'tex') {
 	$gnuplot_input .= "set term postscript eps monochrome\n";
-	$gnuplot_input .= "set output \"/home/httpd/perl/tmp/$filename.eps\"\n";
+	$gnuplot_input .= "set output \"/home/httpd/perl/tmp/".
+	    &Apache::lonnet::unescape($filename).".eps\"\n";
     }
     # grid
     $gnuplot_input .= 'set grid'.$/ if ($plot{'grid'} eq 'on');
@@ -1050,11 +1050,8 @@ sub write_gnuplot_file {
 	    $gnuplot_input.= 
 		$curve->{'function'}.' title "'.
 		$curve->{'name'}.'" with '.
-		$curve->{'linestyle'};
-#
-# gnuplot's term=gif driver does not handle linewidths :(
-# . ' linewidth '. $curve->{'linewidth'};
-#
+                $curve->{'linestyle'};
+            $gnuplot_input.= ' linewidth 4 ' if ($target eq 'tex');
             if (($curve->{'linestyle'} eq 'points')      ||
                 ($curve->{'linestyle'} eq 'linespoints') ||
                 ($curve->{'linestyle'} eq 'errorbars')   ||
@@ -1068,7 +1065,7 @@ sub write_gnuplot_file {
 	    # Store data values in $datatext
 	    my $datatext = '';
 	    #   get new filename
-	    my $datafilename = "$tmpdir/$filename.$i";
+	    my $datafilename = "$tmpdir/$filename.data.$i";
 	    my $fh=Apache::File->new(">$datafilename");
 	    # Compile data
 	    my @Data = @{$curve->{'data'}};
@@ -1087,6 +1084,7 @@ sub write_gnuplot_file {
 	    $gnuplot_input.= '"'.$datafilename.'" title "'.
 		$curve->{'name'}.'" with '.
 		$curve->{'linestyle'};
+            $gnuplot_input.= ' linewidth 4 ' if ($target eq 'tex');
             if (($curve->{'linestyle'} eq 'points')      ||
                 ($curve->{'linestyle'} eq 'linespoints') ||
                 ($curve->{'linestyle'} eq 'errorbars')   ||
@@ -1099,7 +1097,7 @@ sub write_gnuplot_file {
 	}
     }
     # Write the output to a file.
-    my $fh=Apache::File->new(">$tmpdir$filename");
+    my $fh=Apache::File->new(">$tmpdir$filename.data");
     print $fh $gnuplot_input;
     close($fh);
     # That's all folks.