[LON-CAPA-cvs] cvs: loncom /xml lonplot.pm

faziophi faziophi@source.lon-capa.org
Sat, 14 Nov 2009 19:13:37 -0000


faziophi		Sat Nov 14 19:13:37 2009 EDT

  Modified files:              
    /loncom/xml	lonplot.pm 
  Log:
  adding functionality to display x and y axis zero lines as line, thick line, or dotted line
  
  
Index: loncom/xml/lonplot.pm
diff -u loncom/xml/lonplot.pm:1.151 loncom/xml/lonplot.pm:1.152
--- loncom/xml/lonplot.pm:1.151	Fri Jan 30 03:20:10 2009
+++ loncom/xml/lonplot.pm	Sat Nov 14 19:13:36 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Dynamic plot
 #
-# $Id: lonplot.pm,v 1.151 2009/01/30 03:20:10 raeburn Exp $
+# $Id: lonplot.pm,v 1.152 2009/11/14 19:13:36 faziophi Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -455,7 +455,7 @@
 	 },         
      );
 
-my @axis_edit_order = ('color','xmin','xmax','ymin','ymax','xformat', 'yformat');
+my @axis_edit_order = ('color','xmin','xmax','ymin','ymax','xformat', 'yformat', 'xzero', 'yzero');
 my %axis_defaults = 
     (
      color   => {
@@ -507,7 +507,22 @@
          edit_type   => 'choice',
          choices     => ['on', 'off', '2e', '2f'],
          },
-
+     
+     xzero => {
+     	default => 'off',
+     	test	=> sub {$_[0]=~/^(off|line|thick-line|dotted)$/},
+     	description => 'Show x-zero (y=0) axis',
+     	edit_type  => 'choice',
+     	choices	=> ['off', 'line', 'thick-line', 'dotted'],
+     	},
+     
+     yzero => {
+     	default => 'off',
+     	test	=> sub {$_[0]=~/^(off|line|thick-line|dotted)$/},
+     	description => 'Show y-zero (x=0) axis',
+     	edit_type  => 'choice',
+     	choices	=> ['off', 'line', 'thick-line', 'dotted'],
+     	},
      );
 
 my @curve_edit_order = ('color','name','linestyle','linewidth','linetype','pointtype','pointsize','limit');
@@ -1735,6 +1750,26 @@
         }
 	$gnuplot_input .= "set xrange \[$axis{'xmin'}:$axis{'xmax'}\]\n";
 	$gnuplot_input .= "set yrange \[$axis{'ymin'}:$axis{'ymax'}\]\n";
+		if ($axis{'xzero'} ne 'off') {
+			$gnuplot_input .= "set xzeroaxis ";
+			if ($axis{'xzero'} eq 'line' || $axis{'xzero'} eq 'thick-line') {
+				$gnuplot_input .= "lt -1 ";
+				if ($axis{'xzero'} eq 'thick-line') {
+					$gnuplot_input .= "lw 3 ";
+				}
+			}
+			$gnuplot_input .= "\n";
+		}
+		if ($axis{'yzero'} ne 'off') {
+			$gnuplot_input .= "set yzeroaxis ";
+			if ($axis{'yzero'} eq 'line' || $axis{'yzero'} eq 'thick-line') {
+				$gnuplot_input .= "lt -1 ";
+				if ($axis{'yzero'} eq 'thick-line') {
+					$gnuplot_input .= "lw 3 ";
+				}
+			}
+			$gnuplot_input .= "\n";
+		}
     }
     # Key
     if (%key) {