--- loncom/xml/lonplot.pm 2009/01/30 03:20:10 1.151 +++ loncom/xml/lonplot.pm 2009/11/14 19:13:36 1.152 @@ -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 %tic_defaults = }, ); -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 @@ my %axis_defaults = 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 @@ sub write_gnuplot_file { } $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) {