[rkward-cvs] SF.net SVN: rkward:[3663] trunk/rkward/rkward/plugins/plots
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Fri Jun 3 13:23:07 UTC 2011
Revision: 3663
http://rkward.svn.sourceforge.net/rkward/?rev=3663&view=rev
Author: tfry
Date: 2011-06-03 13:23:07 +0000 (Fri, 03 Jun 2011)
Log Message:
-----------
Boxplot gains option for dodging grouped boxes
Modified Paths:
--------------
trunk/rkward/rkward/plugins/plots/box_plot.js
trunk/rkward/rkward/plugins/plots/box_plot.rkh
trunk/rkward/rkward/plugins/plots/box_plot.xml
Modified: trunk/rkward/rkward/plugins/plots/box_plot.js
===================================================================
--- trunk/rkward/rkward/plugins/plots/box_plot.js 2011-06-02 21:36:15 UTC (rev 3662)
+++ trunk/rkward/rkward/plugins/plots/box_plot.js 2011-06-03 13:23:07 UTC (rev 3663)
@@ -8,6 +8,7 @@
function doPrintout (full) {
var grouped_mode = getValue ("data_mode_grouped.numeric");
+ var dodged = grouped_mode && getValue ("dodges");
var names_mode = getValue ("names_mode");
var mean = getValue ("mean");
var pch_mean = getValue ("pch_mean");
@@ -16,10 +17,26 @@
var pch_sd_low = getValue ("pch_sd_low");
var horizontal = getValue ("orientation") == "TRUE";
var plot_adds = getValue ("plotoptions.code.calculate"); //add grid and alike
+ var boxwex = getValue ("boxwex");
+ if (!dodged && (Number (boxwex) != .8)) boxwex = ", boxwex=" + boxwex;
+ else boxwex = "";
+ var positions = "";
if (grouped_mode) {
- echo ('groups <- rk.list (' + getValue ("groups").split ("\n").join (", ") + ')\n');
+ var groups_a = getValue ("groups").split ("\n");
+ var n_dodges = getValue ("dodges");
+ var dodges = groups_a.slice (0, n_dodges);
+ var groups = groups_a.slice (n_dodges);
+ echo ('groups <- rk.list (' + dodges.concat (groups).join (", ") + ')\n');
echo ('data_list <- split (' + getValue ("outcome") + ', groups) #split sample by grouping variables\n');
+ if (dodged) {
+ echo ('# adjust width and position of boxes to achieve dodging\n');
+ echo ('dodge_size <- nlevels (interaction (' + dodges.join (", ") + '))\n');
+ echo ('box_width <- ' + getValue ("boxwex") + ' / dodge_size\n');
+ boxwex = ', boxwex=box_width';
+ echo ('box_positions <- (rep (1:(length (data_list) / dodge_size), each=dodge_size) + (1:dodge_size)*(box_width))\n')
+ positions = ', at=box_positions, xlim=c(min(box_positions)-box_width, max(box_positions)+box_width)';
+ }
} else {
echo ('data_list <- rk.list (' + getValue ("x").split ("\n").join (", ") + ') #convert single sample variables to list\n');
}
@@ -37,7 +54,7 @@
}
echo ('rk.graph.on()\n');
}
- echo ('try (boxplot (data_list, notch = ' + getValue ("notch") + ', outline = ' + getValue("outline") + ', horizontal = ' + getValue("orientation") + getValue ("plotoptions.code.printout") + ')) #actuall boxplot function\n');
+ echo ('try (boxplot (data_list' + boxwex + positions + ', notch = ' + getValue ("notch") + ', outline = ' + getValue("outline") + ', horizontal = ' + getValue("orientation") + getValue ("plotoptions.code.printout") + ')) #actual boxplot function\n');
if (mean == "TRUE") {
if (horizontal) {
echo (' try (points(1:length(data_list) ~ sapply(data_list,mean,na.rm = TRUE),pch=' + pch_mean + ', cex = ' + getValue ("cex_sd_mean") + getValue ("sd_mean_color.code.printout") + ')) #calculates the mean for all data and adds a point at the corresponding position\n');
Modified: trunk/rkward/rkward/plugins/plots/box_plot.rkh
===================================================================
--- trunk/rkward/rkward/plugins/plots/box_plot.rkh 2011-06-02 21:36:15 UTC (rev 3662)
+++ trunk/rkward/rkward/plugins/plots/box_plot.rkh 2011-06-03 13:23:07 UTC (rev 3663)
@@ -14,7 +14,9 @@
<setting id="x">For separate variables mode: Select one or more numerical vectors.</setting>
<setting id="outcome">For single(grouped) variable mode: Select one numerical vectors as the outcome variable.</setting>
<setting id="groups">For single(grouped) variable mode: Select one or more vectors by which to group the outcome variable. Group variables should have the same length as the outcome variable.</setting>
+ <setting id="dodges">For single(grouped) variable mode: Doding boxes within one or more groups can be a nice option when the outcome is split by several group variables. This allows you to select, across how many group variables, boxes should be doged ("0" for no dodging, "1" to dodge only the first group variable).</setting>
<setting id="names_mode">Method for assigning labels to the plot. "default" means, the labels are chosen automatically. If no labels are available, this will generally print the values. The other options allow you to specify the labels as literal string, or as an R statement (e.g. if the names are stored in a different variable in the workspace).</setting>
+ <setting id="Box width">Allows to change the width of the boxes, relative to the entire plot.</setting>
<caption id="tab_options"/>
<setting id="orientation">Orientation of the plot: horizontal or vertical.</setting>
<setting id="notch">Whether to draw notches</setting>
Modified: trunk/rkward/rkward/plugins/plots/box_plot.xml
===================================================================
--- trunk/rkward/rkward/plugins/plots/box_plot.xml 2011-06-02 21:36:15 UTC (rev 3662)
+++ trunk/rkward/rkward/plugins/plots/box_plot.xml 2011-06-03 13:23:07 UTC (rev 3663)
@@ -15,6 +15,7 @@
<connect client="outcome.required" governor="data_mode_grouped"/>
<connect client="groups.visible" governor="data_mode_grouped"/>
<connect client="groups.required" governor="data_mode_grouped"/>
+ <connect client="dodges.visible" governor="data_mode_grouped"/>
<connect client="x.visible" governor="data_mode_grouped.not"/>
<connect client="x.required" governor="data_mode_grouped.not"/>
@@ -44,19 +45,23 @@
<varslot multi="true" type="numeric" source="vars" id="x" label="Variable(s):"/>
<varslot type="numeric" source="vars" id="outcome" label="Outcome variable:"/>
<varslot multi="true" source="vars" id="groups" label="Group variable(s):"/>
+ <spinbox type="integer" id="dodges" label="Dodged groups" min="0" initial="0"/>
</column>
- <stretch/>
- <frame label="Labels">
- <radio id="names_mode" label="Labeling" >
- <option value="default" label="Default labels" checked="true"/>
- <option value="custom" label="Custom labels"/>
- <option value="rexp" label="From R expression"/>
- </radio>
- <input id="names_exp" label="Expression to use for labels" initial="names (x)"/>
- <input id="names_custom" label="Labels (separated by ';')" initial="First label;Second label"/>
- </frame>
+ <column>
+ <frame label="Labels">
+ <radio id="names_mode" label="Labeling" >
+ <option value="default" label="Default labels" checked="true"/>
+ <option value="custom" label="Custom labels"/>
+ <option value="rexp" label="From R expression"/>
+ </radio>
+ <input id="names_exp" label="Expression to use for labels" initial="names (x)"/>
+ <input id="names_custom" label="Labels (separated by ';')" initial="First label;Second label"/>
+ </frame>
+ <spinbox type="real" id="boxwex" label="Box width" min="0" initial="0.8"/>
+ <stretch/>
+ <preview id="preview"/>
+ </column>
</row>
- <preview id="preview"/>
</tab>
<tab label="Options" id="tab_options">
<row>
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