Guest User

Untitled

a guest
Jul 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import smile.interpolation.BicubicInterpolation
  2. import smile.plot.{Palette, heatmap}
  3.  
  4. object Heatmap extends App {
  5. // This is the matrix to be displayed
  6. val z = Array(
  7. Array(1.0, 2.0, 4.0, 1.0),
  8. Array(6.0, 3.0, 5.0, 2.0),
  9. Array(4.0, 2.0, 1.0, 5.0),
  10. Array(5.0, 4.0, 2.0, 3.0)
  11. )
  12.  
  13. // Let's augment this matrix with cubic interpolation
  14. val x = Array(0.0, 1.0, 2.0, 3.0)
  15. val y = Array(0.0, 1.0, 2.0, 3.0)
  16.  
  17. val bicubic = new BicubicInterpolation(x, y, z)
  18. val Z = Array.ofDim[Double](101, 101)
  19.  
  20. for {
  21. i <- 0 to 100
  22. j <- 0 to 100
  23. } Z(i)(j) = bicubic.interpolate(i * 0.03, j * 0.03)
  24.  
  25. heatmap(Z, Palette.jet(256))
  26. }
Add Comment
Please, Sign In to add comment