[rkward-cvs] SF.net SVN: rkward: [1689] trunk/rkward/rkward/plugins/plots
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Wed Mar 21 19:52:28 UTC 2007
Revision: 1689
http://svn.sourceforge.net/rkward/?rev=1689&view=rev
Author: tfry
Date: 2007-03-21 12:52:28 -0700 (Wed, 21 Mar 2007)
Log Message:
-----------
Clean up scatterplot plugin
* local adjustments
* some names changed
* use plot_options where possible (unfortunately, plot_options does not offer different options per var, yet)
Modified Paths:
--------------
trunk/rkward/rkward/plugins/plots/scatterplot.php
trunk/rkward/rkward/plugins/plots/scatterplot.xml
Modified: trunk/rkward/rkward/plugins/plots/scatterplot.php
===================================================================
--- trunk/rkward/rkward/plugins/plots/scatterplot.php 2007-03-21 19:50:44 UTC (rev 1688)
+++ trunk/rkward/rkward/plugins/plots/scatterplot.php 2007-03-21 19:52:28 UTC (rev 1689)
@@ -1,54 +1,38 @@
<?
function preprocess () {
-?>
-rk.temp <- list ()
-<?
}
function calculate () {
- global $Xname;
- global $Yname;
- global $main;
- global $sub;
-
$x = str_replace ("\n", ",", trim (getRK_val ("x"))) ;
$y = str_replace ("\n", ",", trim (getRK_val ("y"))) ;
- /** fetch some values which are needed in more than one place, to avoid mulitple transfer */
- $type = getRK_val ("type");
- $typeCusto = getRK_val ("typeCusto");
- if ($type == "custoType") $type_string = $typeCusto;
- else $type_string = $type;
+ if (getRK_val ("manual_type") == "true") {
+ $type = getRK_val ("custom_type");
+ } else {
+ $type = "c ('" . getRK_val ("pointtype") . "')";
+ }
$col = getRK_val ("col");
$pch = getRK_val ("pch");
$cex = getRK_val ("cex");
- if (getRK_val("isXaxis") == "1") $Xname = getRK_val ("Xname"); else $Xname = "";
- if (getRK_val("isYaxis") == "1") $Yname = getRK_val ("Yname"); else $Yname = "";
- if (getRK_val("isTitle") == "1") $main = getRK_val ("main"); else $main = "";
- if (getRK_val("isSub") == "1") $sub = getRK_val ("sub"); else $sub = "";
?>
<? #input ?>
-rk.temp$Xvar <- list(<? echo ($x) ;?>)
-rk.temp$Yvar <- list(<? echo ($y) ;?>)
-rk.temp$Xval <- <? if (getRK_val("columns") == "custoCol" ) echo (getRK_val("Xscale") . "\n"); else echo ("c(" . $x . ")\n"); ?>
-rk.temp$Yval <- <? if (getRK_val("rows") == "custoRow" ) echo (getRK_val("Yscale") . "\n"); else echo ("c(" . $y . ")\n"); ?>
+Xvars <- list(<? echo ($x) ;?>)
+Yvars <- list(<? echo ($y) ;?>)
<? # verification (is this needed?) ?>
-rk.temp$ok <- TRUE
-if (length(rk.temp$Xvar) != length(rk.temp$Yvar)) {
- rk.temp$ok <- FALSE ;
+if (length(Xvars) != length(Yvars)) {
stop("Unequal number of X and Y variables given")
}
# find range of X/Y values needed
-rk.temp$Xdef <- range (rk.temp$Xval, na.rm=TRUE)
-rk.temp$Ydef <- range (rk.temp$Yval, na.rm=TRUE)
+Xrange <- range (c (Xvars), na.rm=TRUE)
+Yrange <- range (c (Yvars), na.rm=TRUE)
-rk.temp$type <- rep (<? echo ($type_string); ?>, length.out=length (rk.temp$Xvar));
-rk.temp$col <- rep (<? echo ($col); ?>, length.out=length (rk.temp$Xvar));
-rk.temp$cex <- rep (<? echo ($cex); ?>, length.out=length (rk.temp$Xvar));
-rk.temp$pch <- rep (<? echo ($pch); ?>, length.out=length (rk.temp$Xvar));
+type <- rep (<? echo ($type); ?>, length.out=length (Xvars));
+col <- rep (<? echo ($col); ?>, length.out=length (Xvars));
+cex <- rep (<? echo ($cex); ?>, length.out=length (Xvars));
+pch <- rep (<? echo ($pch); ?>, length.out=length (Xvars));
<?
}
@@ -56,50 +40,35 @@
doPrintout (true);
}
-function cleanup () {
-?>
-rm(rk.temp)
-rm(rk.temp.iterator)
-<?
-}
-
function preview () {
preprocess ();
calculate ();
doPrintout (false);
- cleanup ();
}
function doPrintout ($final) {
- global $Xname;
- global $Yname;
- global $main;
- global $sub;
-?>
-if (!rk.temp$ok) stop ()
-
-<? if ($final) { ?>
+ if ($final) { ?>
rk.graph.on()
<? } ?>
try ({
# make frame and axes
- plot(rk.temp$Xdef, rk.temp$Ydef, type="n", xlab = "<? echo ($Xname); ?>", ylab = "<? echo ($Yname); ?>", main = "<? echo ($main); ?>", sub = "<? echo ($sub); ?>", axes = <? getRK("axes") ;?>, log = "<? getRK("logX") ; getRK("logY") ; ?>")
+ plot(Xrange, Yrange, type="n"<? getRK ("plotoptions.code.printout"); ?>)
# plot variables one X/Y pair at a time
- for (rk.temp.iterator in 1:length(rk.temp$Xvar)) {
+ for (i in 1:length(Xvars)) {
points (
- rk.temp$Xvar[[rk.temp.iterator]],
- rk.temp$Yvar[[rk.temp.iterator]],
- type = rk.temp$type[[rk.temp.iterator]],
- col = rk.temp$col[[rk.temp.iterator]],
- cex = rk.temp$cex[[rk.temp.iterator]],
- pch = rk.temp$pch[[rk.temp.iterator]]
+ Xvars[[i]],
+ Yvars[[i]],
+ type = type[[i]],
+ col = col[[i]],
+ cex = cex[[i]],
+ pch = pch[[i]]
)
}
})
+<? if ($final) { ?>
-<? if ($final) { ?>
rk.graph.off()
<? }
}
Modified: trunk/rkward/rkward/plugins/plots/scatterplot.xml
===================================================================
--- trunk/rkward/rkward/plugins/plots/scatterplot.xml 2007-03-21 19:50:44 UTC (rev 1688)
+++ trunk/rkward/rkward/plugins/plots/scatterplot.xml 2007-03-21 19:52:28 UTC (rev 1689)
@@ -6,24 +6,13 @@
first attempt to produce simple plot using the plot function
A duplicate option has to be tested-->
<logic>
- <connect client="Xscale.enabled" governor="columns.number" />
- <connect client="Xscale.required" governor="columns.number" />
- <connect client="Yscale.enabled" governor="rows.number" />
- <connect client="Yscale.required" governor="rows.number" />
- <convert id="XorYscale" mode="or" sources="Xscale.enabled;Yscale.enabled" />
- <connect client="varname.enabled" governor="XorYscale" />
+ <convert id="manual_type" mode="equals" sources="type_mode.string" standard="each" />
+ <convert id="standard_type" mode="equals" sources="type_mode.string" standard="all" />
+ <connect client="pointtype.enabled" governor="standard_type" />
+ <connect client="custom_type.enabled" governor="manual_type" />
+ <connect client="custom_type.required" governor="manual_type" />
- <convert id="customtype" mode="equals" sources="type.string" standard="custoType" />
- <connect client="typeCusto.enabled" governor="customtype" />
- <connect client="typeCusto.required" governor="customtype" />
- <connect client="Xname.enabled" governor="isXaxis.state" />
- <connect client="Xname.required" governor="isXaxis.state" />
- <connect client="Yname.enabled" governor="isYaxis.state" />
- <connect client="Yname.required" governor="isYaxis.state" />
- <connect client="main.enabled" governor="isTitle.state" />
- <connect client="main.required" governor="isTitle.state" />
- <connect client="sub.enabled" governor="isSub.state" />
- <connect client="sub.required" governor="isSub.state" />
+ <set id="plotoptions.allow_type" to="false" />
</logic>
<dialog label="Scatterplot" >
<tabbook>
@@ -39,58 +28,30 @@
</column>
</row>
</tab>
- <tab label="Axes" id="axes_tab">
- <row>
- <varselector id="varname" />
- <column>
- <radio id="columns" label="Value for 'X' scale" >
- <option value="FALSE" label="Default" />
- <option value="custoCol" label="Customize" />
- </radio>
- <varslot multi="false" types="number unknown" source="varname" id="Xscale" />
- <radio id="rows" label="Value for 'Y' scale" >
- <option value="FALSE" label="Default" />
- <option value="custoRow" label="Customize" />
- </radio>
- <varslot multi="false" types="number unknown" id="Yscale" source="varname" />
- </column>
- </row>
- </tab>
- <tab label="Type" id="type_tab">
- <dropdown id="type" label="Type of graphics" >
- <option value="'p'" label="Plot individual dots" />
- <option value="'l'" label="Plot lines" />
- <option value="'b'" label="Plot dots connected by lines (both)" />
- <option value="'o'" label="Plot dots overplotted by lines (both)" />
- <option value="'h'" label="Plot histogram like vertical lines (high-density)" />
- <option value="'s'" label="Stair steps: the top of the vertical defines the point" />
- <option value="'S'" label="Stair steps: the bottom of the vertical defines the point" />
- <option value="custoType" label="Customize" />
- </dropdown>
- <input size="medium" id="typeCusto" label="Give a character vector eg : c('p','l')" />
- </tab>
- <tab label="Names" id="names_tab">
- <row>
- <column>
- <checkbox checked="false" value="1" id="isXaxis" label="Give a name to 'X' axis" />
- <input size="medium" id="Xname" initial="X" label="Name for X axis" />
- <checkbox checked="false" value="1" id="isYaxis" label="Give a name to Y axis" />
- <input size="medium" id="Yname" initial="Y" label="Name of Y axis" />
- <checkbox checked="false" value="1" id="isTitle" label="Give a title" />
- <input size="medium" id="main" />
- <checkbox checked="false" value="1" id="isSub" label="Give a subtitle" />
- <input size="medium" id="sub" />
- </column>
- <column>
- <checkbox value_unchecked="FALSE" checked="true" value="TRUE" id="axes" label="Generate axes" />
- <checkbox value_unchecked="" checked="false" value="x" id="logX" label="X as logarythm" />
- <checkbox value_unchecked="" checked="false" value="y" id="logY" label="Y as logarythm" />
- </column>
- </row>
- </tab>
<tab label="Options" id="options_tab">
+ <embed id="plotoptions" component="rkward::plot_options" as_button="true" label="General plot options"/>
<frame>
<row>
+ <radio id="type_mode" label="Points / lines" >
+ <option value="all" label="Same type for all variables" />
+ <option value="each" label="Different for each variable" />
+ </radio>
+ <column>
+ <dropdown id="pointtype" label="Type of all points/lines" >
+ <option value="p" label="Plot individual points " />
+ <option value="l" label="Plot lines " />
+ <option value="b" label="Plot points connected by lines (both)" />
+ <option value="o" label="Plot points overlaid by lines " />
+ <option value="h" label="Plot vertical lines from points to the zero axis (high-density)" />
+ <option value="s" label="Step-function plots: the left edge defines the point" />
+ <option value="S" label="Step-function plots: the right edge defines the point" />
+ </dropdown>
+ <input size="small" id="custom_type" initial="c ('p', 'l')" label="Vector of type specifiers" />
+ </column>
+ </row>
+ </frame>
+ <frame>
+ <row>
<radio id="color" label="Color" >
<option value="all" label="Same color for all variables" />
<option value="each" label="Different for each variable" />
@@ -104,6 +65,9 @@
</column>
</row>
</frame>
+ </tab>
+ <!-- This way of splitting up options is not really logical, but they are too much for one page -->
+ <tab label="Further options" id="further_options_tab">
<frame>
<row>
<radio id="isCex" label="Size" >
@@ -112,7 +76,7 @@
</radio>
<column>
<text>
- A numerical value giving the amount by which plotting text and symbols should be scaled relative to the default.
+ A numerical value giving the amount by which plotting text and symbols should be scaled relative to the default.
</text>
<input size="small" id="cex" initial="1" label="Enter value - for diff.size. enter a vector -" />
</column>
@@ -126,7 +90,7 @@
</radio>
<column>
<text>
- Either an integer specifying a symbol or a single character to be used as the default in plotting points.
+ Either an integer specifying a symbol or a single character to be used as the default in plotting points.
</text>
<input size="small" id="pch" initial="1" label="Enter value - for diff.symbol. enter a vector -" />
</column>
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