Mercurial > hg > may
comparison yetilab/plot/plot.yeti @ 125:0f362d1de06e
Toward stacked charts
author | Chris Cannam |
---|---|
date | Sat, 20 Apr 2013 12:14:40 +0100 |
parents | 83f127d60c58 |
children | 80eb9b6d4fb9 |
comparison
equal
deleted
inserted
replaced
124:83f127d60c58 | 125:0f362d1de06e |
---|---|
1 module yetilab.plot.plot; | 1 module yetilab.plot.plot; |
2 | 2 |
3 import org.jzy3d.plot3d.builder: Mapper; | 3 import org.jzy3d.plot3d.builder: Mapper; |
4 import org.jzy3d.maths: Range, Coord3d; | 4 import org.jzy3d.maths: Range, Coord3d; |
5 import org.jzy3d.plot3d.primitives: Shape, HistogramBar, FlatLine2d; | 5 import org.jzy3d.plot3d.primitives: Shape, HistogramBar, FlatLine2d, Polygon, Point; |
6 import org.jzy3d.plot3d.primitives.axes.layout.providers: StaticTickProvider; | 6 import org.jzy3d.plot3d.primitives.axes.layout.providers: StaticTickProvider; |
7 import org.jzy3d.plot3d.primitives.axes.layout.renderers: TickLabelMap; | 7 import org.jzy3d.plot3d.primitives.axes.layout.renderers: TickLabelMap; |
8 import org.jzy3d.chart: Chart, ChartLauncher; | 8 import org.jzy3d.chart: Chart, ChartLauncher; |
9 import org.jzy3d.plot3d.builder: Builder; | 9 import org.jzy3d.plot3d.builder: Builder; |
10 import org.jzy3d.plot3d.builder.concrete: OrthonormalGrid; | 10 import org.jzy3d.plot3d.builder.concrete: OrthonormalGrid; |
113 axes#setZAxeLabel(unit); | 113 axes#setZAxeLabel(unit); |
114 axes#setYTickLabelDisplayed(false); | 114 axes#setYTickLabelDisplayed(false); |
115 ChartLauncher#openChart(chart); | 115 ChartLauncher#openChart(chart); |
116 ()); | 116 ()); |
117 | 117 |
118 stack keys xkeys values = | |
119 (stacked = mapIntoHash id \(mapIntoHash id \0 xkeys) keys; | |
120 prev = mapIntoHash id \0 xkeys; | |
121 for xkeys do xk: | |
122 for keys do k: | |
123 value = if xk in values[k] then values[k][xk] else 0 fi; | |
124 height = prev[xk] + value; | |
125 stacked[k][xk] := height; | |
126 prev[xk] := height; | |
127 done; | |
128 done; | |
129 stacked); | |
130 | |
131 plotStacked keys xkeys unit values = | |
132 (chart = new Chart(Quality#Nicest); | |
133 scene = chart#getScene(); | |
134 stacked = stack keys xkeys values; | |
135 var z = 0; | |
136 for keys do k: | |
137 heights = stacked[k]; | |
138 poly = new Polygon(); | |
139 poly#setWireframeDisplayed(true); | |
140 poly#setWireframeColor(Color#random()); | |
141 poly#setFaceDisplayed(true); | |
142 poly#setColor(Color#random()); | |
143 poly#add(new Point(new Coord3d(0, 0, z))); | |
144 var x = 0; | |
145 for xkeys do xk: | |
146 poly#add(new Point(new Coord3d(x, heights[xk], z))); | |
147 x := x + 1; | |
148 done; | |
149 poly#add(new Point(new Coord3d(x - 1, 0, z))); | |
150 scene#add(poly); | |
151 z := z + 1; | |
152 done; | |
153 chart#getView()#setViewPoint(new Coord3d(0, 0, 0)); | |
154 axes = chart#getAxeLayout(); | |
155 axes#setXAxeLabelDisplayed(false); | |
156 axes#setYAxeLabelDisplayed(false); | |
157 axes#setZAxeLabelDisplayed(true); | |
158 axes#setZAxeLabel(unit); | |
159 axes#setYTickLabelDisplayed(false); | |
160 ChartLauncher#openChart(chart); | |
161 ()); | |
118 | 162 |
119 plotStructure structure = | 163 plotStructure structure = |
120 case structure of | 164 case structure of |
121 Grid matrix: | 165 Grid matrix: |
122 plotMatrix matrix; | 166 plotMatrix matrix; |
129 newMatrixLogMapper, | 173 newMatrixLogMapper, |
130 newMapper, | 174 newMapper, |
131 plotMatrix, | 175 plotMatrix, |
132 plotBarChart, | 176 plotBarChart, |
133 plotLines, | 177 plotLines, |
178 stack, | |
179 plotStacked, | |
134 plotStructure, | 180 plotStructure, |
135 } | 181 } |
136 | 182 |