[rkward-cvs] SF.net SVN: rkward:[2662] trunk/rkward/rkward/plugins/plots

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Sep 24 16:14:34 UTC 2009


Revision: 2662
          http://rkward.svn.sourceforge.net/rkward/?rev=2662&view=rev
Author:   tfry
Date:     2009-09-24 16:14:34 +0000 (Thu, 24 Sep 2009)

Log Message:
-----------
Add option to adjust the plotted normal curve to the mean and sd

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/plots/ecdf_plot.php
    trunk/rkward/rkward/plugins/plots/ecdf_plot.rkh
    trunk/rkward/rkward/plugins/plots/ecdf_plot.xml

Modified: trunk/rkward/rkward/plugins/plots/ecdf_plot.php
===================================================================
--- trunk/rkward/rkward/plugins/plots/ecdf_plot.php	2009-09-24 15:44:31 UTC (rev 2661)
+++ trunk/rkward/rkward/plugins/plots/ecdf_plot.php	2009-09-24 16:14:34 UTC (rev 2662)
@@ -1,8 +1,14 @@
 <?
 function preprocess () {
+	$x = getRK_val ("x");
 ?>
-yrange <- range (<? getRK("x"); ?>, na.rm=TRUE)
+yrange <- range (<? echo ($x); ?>, na.rm=TRUE)
 <?
+	if (getRK_val ("th_pnorm") && getRK_val ("adjust_th_pnorm")) { ?>
+data.mean <- mean (<? echo ($x); ?>, na.rm=TRUE)
+data.sd <- sd (<? echo ($x); ?>, na.rm=TRUE)
+<?
+	}
 }
 
 function calculate () {
@@ -29,7 +35,7 @@
 try ({
 	plot.ecdf (<? echo ($x); ?>, <? getRK ("stepfun_options.code.printout"); ?><? getRK ("plotoptions.code.printout"); ?>)
 <?	if (getRK_val ("th_pnorm")) { ?>
-	curve (pnorm, from=yrange[1], to=yrange[2], add=TRUE, <? getRK ("col_thnorm.code.printout"); ?>)
+	curve (pnorm<? if (getRK_val ("adjust_th_pnorm")) echo " (x, mean=data.mean, sd=data.sd)"; ?>, from=yrange[1], to=yrange[2], add=TRUE, <? getRK ("col_thnorm.code.printout"); ?>)
 <?	}
 	if (getRK_val ("rug")) { ?>
 	rug (<? echo ($x); ?>, <? getRK ("ticksize"); ?>, <? getRK ("lwd"); ?>, <? getRK ("side"); ?><? getRK ("col_rug.code.printout"); ?>)

Modified: trunk/rkward/rkward/plugins/plots/ecdf_plot.rkh
===================================================================
--- trunk/rkward/rkward/plugins/plots/ecdf_plot.rkh	2009-09-24 15:44:31 UTC (rev 2661)
+++ trunk/rkward/rkward/plugins/plots/ecdf_plot.rkh	2009-09-24 16:14:34 UTC (rev 2662)
@@ -10,9 +10,10 @@
 		<caption id="tab_variables"/>
 		<setting id="x">The variable to plot the ECDF</setting>
 		<caption id="tab_stepfun_opts"/>
-		<setting id="stepfun_options">Options to change the look of the ECDF plot itself.Refer to <link href="rkward://component/plot_stepfun_options"/> for details.</setting>
+		<setting id="stepfun_options">Options to change the look of the ECDF plot itself. Refer to <link href="rkward://component/plot_stepfun_options"/> for details.</setting>
 		<caption id="tab_further_opts"/>
 		<setting id="th_pnorm">Should a theoretical normal distribution curve be added to the plot?</setting>
+		<setting id="adjust_th_pnorm">Should the normal distribution curve be adjusted to match the mean and standard deviation of the plotted data? If this is not set a normal curve with mean 0 and sd 1 is drawn.</setting>
 		<setting id="col_thnorm">Color of the theoretical normal distribution curve.</setting>
 		<setting id="rug">Should a rug be added to the plot?</setting>
 		<setting id="side">Should the rug be added above or below the plot?</setting>

Modified: trunk/rkward/rkward/plugins/plots/ecdf_plot.xml
===================================================================
--- trunk/rkward/rkward/plugins/plots/ecdf_plot.xml	2009-09-24 15:44:31 UTC (rev 2661)
+++ trunk/rkward/rkward/plugins/plots/ecdf_plot.xml	2009-09-24 16:14:34 UTC (rev 2662)
@@ -13,6 +13,7 @@
 		<set id="stepfun_options.allow_col01line" to="true"/>
 
 		<connect client="col_thnorm.enabled" governor="th_pnorm.state"/>
+		<connect client="adjust_th_pnorm.enabled" governor="th_pnorm.state"/>
 
 		<connect client="side.enabled" governor="rug.state"/>
 		<connect client="ticksize.enabled" governor="rug.state"/>
@@ -38,6 +39,7 @@
 			<tab label="Further options" id="tab_further_opts">
 				<frame label="Theoretical Normal Distribution">
 					<checkbox value_unchecked="0" value="1" checked="false" id="th_pnorm" label="Draw Theoretical Normal Distribution" />
+					<checkbox value_unchecked="0" value="1" checked="true" id="adjust_th_pnorm" label="Adjust to mean and sd of data" />
 					<embed id="col_thnorm" component="rkward::color_chooser" label="Color"/>
 				</frame>
 				<frame label="Rug">


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list