Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.

Commit ff23f42

Browse files
committed
Experiment with typed columns in models/anscombe
1 parent 2fa618b commit ff23f42

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

examples/src/main/scala/models/Anscombe.scala

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package io.continuum.bokeh
22
package examples
33
package models
44

5-
import breeze.linalg.{DenseMatrix,linspace}
5+
import breeze.linalg.{DenseMatrix,DenseVector,linspace}
66

77
import thirdparty._
88

@@ -20,7 +20,7 @@ object Anscombe extends Example {
2020
( 7.0, 4.82, 7.0, 7.26, 7.0, 6.42, 8.0, 7.91),
2121
( 5.0, 5.68, 5.0, 4.74, 5.0, 5.73, 8.0, 6.89))
2222

23-
object circles_source extends ColumnDataSource {
23+
object circles extends ColumnDataSource {
2424
val xi = column(anscombe_quartet(::, 0))
2525
val yi = column(anscombe_quartet(::, 1))
2626
val xii = column(anscombe_quartet(::, 2))
@@ -31,17 +31,17 @@ object Anscombe extends Example {
3131
val yiv = column(anscombe_quartet(::, 7))
3232
}
3333

34-
object lines_source extends ColumnDataSource {
34+
object lines extends ColumnDataSource {
3535
val x = column(linspace(-0.5, 20.5, 10))
3636
val y = column(x.value*0.5 + 3.0)
3737
}
3838

39-
import lines_source.{x,y}
40-
4139
val xdr = new Range1d().start(-0.5).end(20.5)
4240
val ydr = new Range1d().start(-0.5).end(20.5)
4341

44-
def make_plot(title: String, xname: Symbol, yname: Symbol) = {
42+
type Col = circles.Column[DenseVector, Double]
43+
44+
def make_plot(title: String, x_col: Col, y_col: Col) = {
4545
val plot = new Plot()
4646
.x_range(xdr)
4747
.y_range(ydr)
@@ -57,19 +57,19 @@ object Anscombe extends Example {
5757
val xgrid = new Grid().plot(plot).axis(xaxis).dimension(0)
5858
val ygrid = new Grid().plot(plot).axis(yaxis).dimension(1)
5959
val line_renderer = new GlyphRenderer()
60-
.data_source(lines_source)
61-
.glyph(new Line().x(x).y(y).line_color("#666699").line_width(2))
60+
.data_source(lines)
61+
.glyph(new Line().x(lines.x).y(lines.y).line_color("#666699").line_width(2))
6262
val circle_renderer = new GlyphRenderer()
63-
.data_source(circles_source)
64-
.glyph(new Circle().x(xname).y(yname).size(12).fill_color("#cc6633").line_color("#cc6633").fill_alpha(50%%))
63+
.data_source(circles)
64+
.glyph(new Circle().x(x_col).y(y_col).size(12).fill_color("#cc6633").line_color("#cc6633").fill_alpha(50%%))
6565
plot.renderers := List(xaxis, yaxis, xgrid, ygrid, line_renderer, circle_renderer)
6666
plot
6767
}
6868

69-
val I = make_plot("I", 'xi, 'yi)
70-
val II = make_plot("II", 'xii, 'yii)
71-
val III = make_plot("III", 'xiii, 'yiii)
72-
val IV = make_plot("IV", 'xiv, 'yiv)
69+
val I = make_plot("I", circles.xi, circles.yi)
70+
val II = make_plot("II", circles.xii, circles.yii)
71+
val III = make_plot("III", circles.xiii, circles.yiii)
72+
val IV = make_plot("IV", circles.xiv, circles.yiv)
7373

7474
val children = List(List(I, II), List(III, IV))
7575
val grid = new GridPlot().children(children).width(800)

0 commit comments

Comments
 (0)