version 1.161, 2012/07/17 09:54:48
|
version 1.162, 2012/07/17 10:49:53
|
Line 1636 sub get_attributes{
|
Line 1636 sub get_attributes{
|
} |
} |
return ; |
return ; |
} |
} |
|
## |
|
# Generate tic mark specifications. |
|
# |
|
# @param type - type of tics (xtics or ytics). |
|
# @param spec - Reference to a hash that contains the tic specification. |
|
# @param target - 'tex' if hard copy target. |
|
# |
|
# @return string - the tic specification command. |
|
# |
|
sub generate_tics { |
|
my ($type, $spec, $target) = @_; |
|
my $result = ''; |
|
|
|
|
|
if (defined %$spec) { |
|
|
|
|
|
|
|
# Major tics: |
|
|
|
$result .= "set $type $spec->{'location'} "; |
|
$result .= ($spec->{'mirror'} eq 'on') ? 'mirror ' : 'nomirror '; |
|
$result .= "$spec->{'start'}, "; |
|
$result .= "$spec->{'increment'}, "; |
|
$result .= "$spec->{'end'} "; |
|
if ($target eq 'tex' ) { |
|
$result .= 'font "Helvetica,22"'; |
|
} |
|
$result .= "\n"; |
|
|
|
# minor frequency: |
|
|
|
if ($spec->{'minorfreq'} != 0) { |
|
$result .= "set m$type $spec->{'minorfreq'}\n"; |
|
} |
|
} else { |
|
$result .= "set $type font " . '"Helvetica,22"' ."\n"; |
|
} |
|
|
|
|
|
return $result; |
|
} |
|
|
##------------------------------------------------------- write_gnuplot_file |
##------------------------------------------------------- write_gnuplot_file |
sub write_gnuplot_file { |
sub write_gnuplot_file { |
Line 1778 sub write_gnuplot_file {
|
Line 1820 sub write_gnuplot_file {
|
$gnuplot_input .= "set ylabel \"$ylabel\" $extra_space_y \n" if (defined($ylabel)); |
$gnuplot_input .= "set ylabel \"$ylabel\" $extra_space_y \n" if (defined($ylabel)); |
} |
} |
# tics |
# tics |
if (%xtics) { |
$gnuplot_input .= &generate_tics('xtics', \%xtics, $target); |
$gnuplot_input .= "set xtics $xtics{'location'} "; |
|
$gnuplot_input .= ( $xtics{'mirror'} eq 'on'?"mirror ":"nomirror "); |
$gnuplot_input .= &generate_tics('ytics', \%ytics, $target); |
$gnuplot_input .= "$xtics{'start'}, "; |
|
$gnuplot_input .= "$xtics{'increment'}, "; |
|
$gnuplot_input .= "$xtics{'end'} "; |
|
if ($target eq 'tex') { |
|
$gnuplot_input .= 'font "Helvetica,22"'; # Needed in iso 8859-1 enc. |
|
} |
|
$gnuplot_input .= "\n"; |
|
if ($xtics{'minorfreq'} != 0) { |
|
$gnuplot_input .= "set mxtics ".$xtics{'minorfreq'}."\n"; |
|
} |
|
} else { |
|
if ($target eq 'tex') { |
|
$gnuplot_input .= 'set xtics font "Helvetica,22"'."\n"; # needed in iso 8859-1 enc |
|
} |
|
} |
|
if (%ytics) { |
|
$gnuplot_input .= "set ytics $ytics{'location'} "; |
|
$gnuplot_input .= ( $ytics{'mirror'} eq 'on'?"mirror ":"nomirror "); |
|
$gnuplot_input .= "$ytics{'start'}, "; |
|
$gnuplot_input .= "$ytics{'increment'}, "; |
|
$gnuplot_input .= "$ytics{'end'} "; |
|
if ($target eq 'tex') { |
|
$gnuplot_input .= 'font "Helvetica,22"'; # Needed in iso-8859-1 encoding. |
|
} |
|
$gnuplot_input .= "\n"; |
|
if ($ytics{'minorfreq'} != 0) { |
|
$gnuplot_input .= "set mytics ".$ytics{'minorfreq'}."\n"; |
|
} |
|
} else { |
|
if ($target eq 'tex') { |
|
$gnuplot_input .= 'set ytics font "Helvetica,22"'."\n"; # Needed for iso 8859-1 enc. |
|
} |
|
} |
|
# axis |
# axis |
if (%axis) { |
if (%axis) { |
if ($axis{'xformat'} ne 'on') { |
if ($axis{'xformat'} ne 'on') { |
Line 2004 sub write_gnuplot_file {
|
Line 2014 sub write_gnuplot_file {
|
$linestyle_index++; # Each curve get a unique linestyle. |
$linestyle_index++; # Each curve get a unique linestyle. |
} |
} |
# Write the output to a file. |
# Write the output to a file. |
|
&Apache::lonnet::logthis($gnuplot_input); |
open (my $fh, "> $tmpdir$filename.data"); |
open (my $fh, "> $tmpdir$filename.data"); |
binmode($fh, ':utf8'); |
binmode($fh, ':utf8'); |
print $fh $gnuplot_input; |
print $fh $gnuplot_input; |