annotate tools/plotting/xy_plot.xml @ 1:cdcb0ce84a1b

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:45:15 -0500
parents 9071e359b9a3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1 <tool id="XY_Plot_1" name="Plotting tool" version="1.0.1">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2 <description>for multiple series and graph types</description>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3 <command interpreter="bash">r_wrapper.sh $script_file</command>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
4
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
5 <inputs>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
6 <param name="main" type="text" value="" size="30" label="Plot Title"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
7 <param name="xlab" type="text" value="" size="30" label="Label for x axis"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
8 <param name="ylab" type="text" value="" size="30" label="Label for y axis"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
9 <repeat name="series" title="Series">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
10 <param name="input" type="data" format="tabular" label="Dataset"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
11 <param name="xcol" type="data_column" data_ref="input" label="Column for x axis"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
12 <param name="ycol" type="data_column" data_ref="input" label="Column for y axis"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
13 <conditional name="series_type">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
14 <param name="type" type="select" label="Series Type">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
15 <option value="line" selected="true">Line</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
16 <option value="points">Points</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
17 </param>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
18 <when value="line">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
19 <param name="lty" type="select" label="Line Type">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
20 <option value="1">Solid</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
21 <option value="2">Dashed</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
22 <option value="3">Dotted</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
23 </param>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
24 <param name="col" type="select" label="Line Color">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
25 <option value="1">Black</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
26 <option value="2">Red</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
27 <option value="3">Green</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
28 <option value="4">Blue</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
29 <option value="5">Cyan</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
30 <option value="6">Magenta</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
31 <option value="7">Yellow</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
32 <option value="8">Gray</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
33 </param>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
34 <param name="lwd" type="float" label="Line Width" value="1.0"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
35 </when>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
36 <when value="points">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
37 <param name="pch" type="select" label="Point Type">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
38 <option value="1">Circle (hollow)</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
39 <option value="2">Triangle (hollow)</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
40 <option value="3">Cross</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
41 <option value="4">Diamond (hollow)</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
42 <option value="15">Square (filled)</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
43 <option value="16">Circle (filled)</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
44 <option value="17">Triangle (filled)</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
45 </param>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
46 <param name="col" type="select" label="Point Color">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
47 <option value="1">Black</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
48 <option value="2">Red</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
49 <option value="3">Green</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
50 <option value="4">Blue</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
51 <option value="5">Cyan</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
52 <option value="6">Magenta</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
53 <option value="7">Yellow</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
54 <option value="8">Gray</option>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
55 </param>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
56 <param name="cex" type="float" label="Point Scale" value="1.0"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
57 </when>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
58 </conditional>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
59 </repeat>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
60 </inputs>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
61
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
62 <configfiles>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
63 <configfile name="script_file">
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
64 ## Setup R error handling to go to stderr
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
65 options( show.error.messages=F,
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
66 error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
67 ## Determine range of all series in the plot
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
68 xrange = c( NULL, NULL )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
69 yrange = c( NULL, NULL )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
70 #for $i, $s in enumerate( $series )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
71 s${i} = read.table( "${s.input.file_name}" )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
72 x${i} = s${i}[,${s.xcol}]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
73 y${i} = s${i}[,${s.ycol}]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
74 xrange = range( x${i}, xrange )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
75 yrange = range( y${i}, yrange )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
76 #end for
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
77 ## Open output PDF file
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
78 pdf( "${out_file1}" )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
79 ## Dummy plot for axis / labels
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
80 plot( NULL, type="n", xlim=xrange, ylim=yrange, main="${main}", xlab="${xlab}", ylab="${ylab}" )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
81 ## Plot each series
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
82 #for $i, $s in enumerate( $series )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
83 #if $s.series_type['type'] == "line"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
84 lines( x${i}, y${i}, lty=${s.series_type.lty}, lwd=${s.series_type.lwd}, col=${s.series_type.col} )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
85 #elif $s.series_type.type == "points"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
86 points( x${i}, y${i}, pch=${s.series_type.pch}, cex=${s.series_type.cex}, col=${s.series_type.col} )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
87 #end if
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
88 #end for
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
89 ## Close the PDF file
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
90 devname = dev.off()
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
91 </configfile>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
92 </configfiles>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
93
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
94 <outputs>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
95 <data format="pdf" name="out_file1" />
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
96 </outputs>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
97
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
98 <tests>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
99 <test>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
100 <param name="main" value="Example XY Plot"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
101 <param name="xlab" value="Column 1"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
102 <param name="ylab" value="Column 2"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
103 <param name="input" value="2.tabular" ftype="tabular"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
104 <param name="xcol" value="1"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
105 <param name="ycol" value="2"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
106 <param name="type" value="line"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
107 <param name="lty" value="2"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
108 <param name="col" value="2"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
109 <param name="lwd" value="1.0"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
110 <output name="out_file1" file="XY_Plot_1_out.pdf"/>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
111 </test>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
112 </tests>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
113 <help>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
114 .. class:: infomark
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
115
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
116 This tool allows you to plot values contained in columns of a dataset against each other and also allows you to have different series corresponding to the same or different datasets in one plot.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
117
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
118 -----
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
119
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
120 .. class:: warningmark
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
121
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
122 This tool throws an error if the columns selected for plotting are absent or are not numeric and also if the lengths of these columns differ.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
123
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
124 -----
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
125
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
126 **Example**
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
127
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
128 Input file::
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
129
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
130 1 68 4.1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
131 2 71 4.6
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
132 3 62 3.8
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
133 4 75 4.4
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
134 5 58 3.2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
135 6 60 3.1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
136 7 67 3.8
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
137 8 68 4.1
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
138 9 71 4.3
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
139 10 69 3.7
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
140
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
141 Create a two series XY plot on the above data:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
142
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
143 - Series 1: Red Dashed-Line plot between columns 1 and 2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
144 - Series 2: Blue Circular-Point plot between columns 3 and 2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
145
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
146 .. image:: ./static/images/xy_example.jpg
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
147 </help>
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
148 </tool>