Mercurial > hg > may
diff yetilab/plot/plot.yeti @ 108:8f6c2f87dc35
Some basic plotting
author | Chris Cannam |
---|---|
date | Fri, 29 Mar 2013 22:36:29 +0000 |
parents | |
children | f039eec93d50 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/yetilab/plot/plot.yeti Fri Mar 29 22:36:29 2013 +0000 @@ -0,0 +1,50 @@ +module yetilab.plot.plot; + +import org.jzy3d.plot3d.builder: Mapper; +import org.jzy3d.maths: Range; +import org.jzy3d.plot3d.primitives: Shape; +import org.jzy3d.chart: Chart, ChartLauncher; +import org.jzy3d.plot3d.builder: Builder; +import org.jzy3d.plot3d.builder.concrete: OrthonormalGrid; +import org.jzy3d.colors.colormaps: ColorMapRainbow; +import org.jzy3d.colors: ColorMapper; +import org.jzy3d.colors: Color; +import org.jzy3d.plot3d.rendering.canvas: Quality; + +newMatrixMapper matrix = + (class MMapper extends Mapper + double f(double x, double y) + matrix.getAt y x + end; + new MMapper()); + +newMatrixLogMapper matrix = + (class MMapper extends Mapper + double f(double x, double y) + ln (matrix.getAt y x) + end; + new MMapper()); + +newMapper mapFunction = + (class FMapper extends Mapper + double f(double x, double y) + mapFunction x y + end; + new FMapper()); + +plot matrix = + (mapper = newMatrixLogMapper matrix; + size = matrix.size; + xrange = new Range(1, size.columns - 1); + yrange = new Range(1, size.rows - 1); + grid = new OrthonormalGrid(xrange, size.columns, yrange, size.rows); + surface = Builder#buildOrthonormal(grid, mapper); + surface#setFaceDisplayed(true); + surface#setWireframeDisplayed(true); + surface#setWireframeColor(Color#BLACK); + chart = new Chart(Quality#Nicest); + chart#getScene()#getGraph()#add(surface); + ChartLauncher#openChart(chart)); + +{ plot } +