comparison yetilab/plot/plot.yeti @ 151:d5a5a0d7ce30

Return Series for fixed-rate single-valued results from plugin; allow more than one plot per chart, with series plot
author Chris Cannam
date Mon, 29 Apr 2013 22:14:28 +0100
parents e65bdec6470e
children d9308083df77
comparison
equal deleted inserted replaced
150:e65bdec6470e 151:d5a5a0d7ce30
32 double f(double x, double y) 32 double f(double x, double y)
33 mapFunction x y 33 mapFunction x y
34 end; 34 end;
35 new FMapper()); 35 new FMapper());
36 36
37 plotMatrix matrix = 37 plotMatrix chart matrix is ~Chart -> 'a -> () =
38 (mapper = newMatrixMapper matrix; 38 (mapper = newMatrixMapper matrix;
39 size = matrix.size; 39 size = matrix.size;
40 xrange = new Range(0, size.columns - 1); 40 xrange = new Range(0, size.columns - 1);
41 yrange = new Range(0, size.rows - 1); 41 yrange = new Range(0, size.rows - 1);
42 grid = new OrthonormalGrid(xrange, size.columns, yrange, size.rows); 42 grid = new OrthonormalGrid(xrange, size.columns, yrange, size.rows);
44 surface = Builder#buildOrthonormal(grid, mapper); //??? big? 44 surface = Builder#buildOrthonormal(grid, mapper); //??? big?
45 println "Z Bounds: \(surface#getBounds()#getZmin()) -> \(surface#getBounds()#getZmax())"; 45 println "Z Bounds: \(surface#getBounds()#getZmin()) -> \(surface#getBounds()#getZmax())";
46 surface#setFaceDisplayed(true); 46 surface#setFaceDisplayed(true);
47 surface#setWireframeDisplayed(true); 47 surface#setWireframeDisplayed(true);
48 surface#setWireframeColor(Color#BLACK); 48 surface#setWireframeColor(Color#BLACK);
49 // chart = new Chart(Quality#Fastest, "swing");
50 chart = new Chart(Quality#Nicest);
51 chart#getScene()#getGraph()#add(surface); 49 chart#getScene()#getGraph()#add(surface);
52 ChartLauncher#openChart(chart);
53 ()); 50 ());
54 51
55 plotCurve curve = 52 plotCurve chart curve is ~Chart -> 'a -> () =
56 (chart = new Chart(Quality#Nicest); 53 (scene = chart#getScene();
57 scene = chart#getScene();
58 xx = map (.time) curve; 54 xx = map (.time) curve;
59 yy = map (.value) curve; 55 yy = map (.value) curve;
60 line = new FlatLine2d(xx as ~float[], yy as ~float[], 0); 56 line = new FlatLine2d(xx as ~float[], yy as ~float[], 0);
61 line#setWireframeDisplayed(true); 57 line#setWireframeDisplayed(true);
62 line#setWireframeColor(Color#BLACK); 58 line#setWireframeColor(Color#BLACK);
70 axes#setYAxeLabelDisplayed(false); 66 axes#setYAxeLabelDisplayed(false);
71 axes#setZAxeLabelDisplayed(true); 67 axes#setZAxeLabelDisplayed(true);
72 axes#setZAxeLabel("unit goes here"); //!!! 68 axes#setZAxeLabel("unit goes here"); //!!!
73 axes#setYTickLabelDisplayed(false); 69 axes#setYTickLabelDisplayed(false);
74 */ 70 */
75 ChartLauncher#openChart(chart);
76 ()); 71 ());
77 72
78 plotSeries series = 73 plotSeries chart { start, step, values } is ~Chart -> 'a -> () =
79 (chart = new Chart(Quality#Nicest); 74 (scene = chart#getScene();
80 scene = chart#getScene(); 75 xx = map do i: start + step * i done [0..length values - 1];
81 xx = [0..length series - 1]; 76 yy = list values;
82 yy = list series;
83 line = new FlatLine2d(xx as ~float[], yy as ~float[], 0); 77 line = new FlatLine2d(xx as ~float[], yy as ~float[], 0);
84 line#setWireframeDisplayed(true); 78 line#setWireframeDisplayed(true);
85 line#setWireframeColor(Color#BLACK); 79 line#setWireframeColor(Color#BLACK);
86 line#setWireframeWidth(2); 80 line#setWireframeWidth(2);
87 line#setFaceDisplayed(false); 81 line#setFaceDisplayed(false);
93 axes#setYAxeLabelDisplayed(false); 87 axes#setYAxeLabelDisplayed(false);
94 axes#setZAxeLabelDisplayed(true); 88 axes#setZAxeLabelDisplayed(true);
95 axes#setZAxeLabel("unit goes here"); //!!! 89 axes#setZAxeLabel("unit goes here"); //!!!
96 axes#setYTickLabelDisplayed(false); 90 axes#setYTickLabelDisplayed(false);
97 */ 91 */
98 ChartLauncher#openChart(chart);
99 ()); 92 ());
100 93
101 plotStructure structure = 94 plot structures =
102 case structure of 95 (chart = new Chart(Quality#Nicest);
103 Grid matrix: 96 for structures
104 plotMatrix matrix; 97 \case of
105 Curve curve: 98 Grid matrix:
106 plotCurve curve; 99 plotMatrix chart matrix;
107 Series series: 100 Curve curve:
108 plotSeries series; 101 plotCurve chart curve;
109 _: failWith "Cannot plot this structure (only grids implemented so far)"; 102 Series series:
110 esac; 103 plotSeries chart series;
104 other:
105 failWith "Unable to plot \(other)";
106 esac;
107 ChartLauncher#openChart(chart);
108 chart);
111 109
112 { 110 {
113 newMatrixMapper, 111 newMatrixMapper,
114 newMatrixLogMapper, 112 newMatrixLogMapper,
115 newMapper, 113 newMapper,
116 plotMatrix, 114 plotMatrix,
117 plotStructure, 115 plotCurve,
116 plotSeries,
117 plot,
118 } 118 }
119 119