annotate yetilab/plot/plot.yeti @ 147:e16e42c55a20

Add autocorrelation
author Chris Cannam
date Sat, 27 Apr 2013 23:56:15 +0100
parents 4065178f776b
children b973e8a31bd6
rev   line source
Chris@108 1 module yetilab.plot.plot;
Chris@108 2
Chris@108 3 import org.jzy3d.plot3d.builder: Mapper;
Chris@119 4 import org.jzy3d.maths: Range, Coord3d;
Chris@108 5 import org.jzy3d.chart: Chart, ChartLauncher;
Chris@108 6 import org.jzy3d.plot3d.builder: Builder;
Chris@108 7 import org.jzy3d.plot3d.builder.concrete: OrthonormalGrid;
Chris@108 8 import org.jzy3d.colors.colormaps: ColorMapRainbow;
Chris@119 9 import org.jzy3d.colors: ColorMapper, Color;
Chris@108 10 import org.jzy3d.plot3d.rendering.canvas: Quality;
Chris@119 11 import org.jzy3d.plot3d.rendering.view.modes: ViewPositionMode;
Chris@108 12
Chris@108 13 newMatrixMapper matrix =
Chris@108 14 (class MMapper extends Mapper
Chris@108 15 double f(double x, double y)
Chris@117 16 result = matrix.getAt y x;
Chris@117 17 println "f(\(x),\(y)) -> \(result)";
Chris@117 18 result
Chris@108 19 end;
Chris@108 20 new MMapper());
Chris@108 21
Chris@108 22 newMatrixLogMapper matrix =
Chris@108 23 (class MMapper extends Mapper
Chris@108 24 double f(double x, double y)
Chris@108 25 ln (matrix.getAt y x)
Chris@108 26 end;
Chris@108 27 new MMapper());
Chris@108 28
Chris@108 29 newMapper mapFunction =
Chris@108 30 (class FMapper extends Mapper
Chris@108 31 double f(double x, double y)
Chris@108 32 mapFunction x y
Chris@108 33 end;
Chris@108 34 new FMapper());
Chris@108 35
Chris@115 36 plotMatrix matrix =
Chris@117 37 (mapper = newMatrixMapper matrix;
Chris@108 38 size = matrix.size;
Chris@119 39 xrange = new Range(0, size.columns - 1);
Chris@119 40 yrange = new Range(0, size.rows - 1);
Chris@108 41 grid = new OrthonormalGrid(xrange, size.columns, yrange, size.rows);
Chris@112 42 println "Matrix size: \(size)";
Chris@117 43 surface = Builder#buildOrthonormal(grid, mapper); //??? big?
Chris@117 44 println "Z Bounds: \(surface#getBounds()#getZmin()) -> \(surface#getBounds()#getZmax())";
Chris@121 45 surface#setFaceDisplayed(true);
Chris@108 46 surface#setWireframeDisplayed(true);
Chris@108 47 surface#setWireframeColor(Color#BLACK);
Chris@112 48 // chart = new Chart(Quality#Fastest, "swing");
Chris@112 49 chart = new Chart(Quality#Nicest);
Chris@108 50 chart#getScene()#getGraph()#add(surface);
Chris@115 51 ChartLauncher#openChart(chart);
Chris@115 52 ());
Chris@108 53
Chris@110 54 plotStructure structure =
Chris@110 55 case structure of
Chris@110 56 Grid matrix:
Chris@115 57 plotMatrix matrix;
Chris@110 58 //!!!
Chris@110 59 _: failWith "Cannot plot this structure (only grids implemented so far)";
Chris@110 60 esac;
Chris@108 61
Chris@115 62 {
Chris@119 63 newMatrixMapper,
Chris@119 64 newMatrixLogMapper,
Chris@119 65 newMapper,
Chris@115 66 plotMatrix,
Chris@119 67 plotStructure,
Chris@115 68 }
Chris@110 69