Plot coordinate pairs: Difference between revisions

Content added Content deleted
Line 973: Line 973:
if (f2 >= xs.max) f2 else (round(xs.max/f1)+1)*f1
if (f2 >= xs.max) f2 else (round(xs.max/f1)+1)*f1
}
}
//val ymax = {val f1 = pow(10,log10(ys.max).toInt); round(ys.max/f1)*f1}
val ymax = {
val ymax = {
val f1 = pow(10,log10(ys.max).toInt)
val f1 = pow(10,log10(ys.max).toInt)
Line 998: Line 997:
a_path.lineTo(pymax.dx, pymax.dy) //y-axis
a_path.lineTo(pymax.dx, pymax.dy) //y-axis
// interval signs:
// interval signs:
(0 to xs.size-1).map(i=>Coord(i*xinterv, 0))
(0 to xs.size-1).map(i=>Coord(i*xinterv, 0)).map(p=>{a_path.moveTo(p.dx,p.dy);a_path.lineTo(p.dx,p.dy+5)})
.map(p=>{a_path.moveTo(p.dx,p.dy);a_path.lineTo(p.dx,p.dy+5)})
(0 to xs.size-1).map(i=>Coord(0, i*yinterv)).map(p=>{a_path.moveTo(p.dx,p.dy);a_path.lineTo(p.dx-5,p.dy)})
(0 to xs.size).map(i=>Coord(0, i*yinterv))
.map(p=>{a_path.moveTo(p.dx,p.dy);a_path.lineTo(p.dx-5,p.dy)})


//grid:
//grid:
var g_path = new geom.GeneralPath
var g_path = new geom.GeneralPath
(1 to xs.size).map(i=>Coord(i*xinterv, 0))
(1 to xs.size).map(i=>Coord(i*xinterv, 0)).map(p=>{g_path.moveTo(p.dx,p.dy);g_path.lineTo(Coord(p.x,ymax).dx,Coord(p.x,ymax).dy)})
.map(p=>{g_path.moveTo(p.dx,p.dy);g_path.lineTo(Coord(p.x,ymax).dx,Coord(p.x,ymax).dy)})
(1 to xs.size).map(i=>Coord(0, i*yinterv)).map(p=>{g_path.moveTo(p.dx,p.dy);g_path.lineTo(Coord(xmax,p.y).dx,Coord(xmax,p.y).dy)})
(1 to xs.size).map(i=>Coord(0, i*yinterv))
.map(p=>{g_path.moveTo(p.dx,p.dy);g_path.lineTo(Coord(xmax,p.y).dx,Coord(xmax,p.y).dy)})
//labeling:
//labeling:
val xlabels = (0 to xs.size)
val xlabels = (0 to xs.size).map(i=>{val p=Coord(i*xinterv,0); Triple(p.x.toInt.toString,p.dx-3,p.dy+20)})
.map(i=>{val p=Coord(i*xinterv,0); Triple(p.x.toInt.toString,p.dx-3,p.dy+20)})
val ylabels = (0 to xs.size).map(i=>{val p=Coord(0,i*yinterv); Triple(p.y.toInt.toString,p.dx-30,p.dy+5)})
val ylabels = (0 to xs.size)
.map(i=>{val p=Coord(0,i*yinterv); Triple(p.y.toInt.toString,p.dx-30,p.dy+5)})
//curve:
//curve:
Line 1,038: Line 1,031:
}
}
val xs = List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
val xs = List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
val ys = List(2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0)
val ys = List(2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0)