Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active May 8, 2023 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacr/f2d934a6cd43c3bef9c9aae80b90f53f to your computer and use it in GitHub Desktop.
Save dacr/f2d934a6cd43c3bef9c9aae80b90f53f to your computer and use it in GitHub Desktop.
plotting with smile / published by https://github.com/dacr/code-examples-manager #2b837969-72e0-49a7-a257-d09c6d5c091b/341919a327dbfe6235788c7fe71f0e91af775cb8
// summary : plotting with smile
// keywords : smile, plotting
// publish : gist
// authors : smile documentation
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// id : 2b837969-72e0-49a7-a257-d09c6d5c091b
// created-on : 2020-10-11T17:33:19Z
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
// ---------------------
//> using scala "3.2.2"
//> using dep "com.github.haifengl:smile-scala_2.13:3.0.1"
// ---------------------
import scala.math._
import java.awt.Color.RED
// those smile imports (and many more) are available by default in REPL mode
import smile.plot._
import smile.plot.swing._
import smile.plot.Render._
implicit val renderer:Canvas=>Unit = JWindow.apply
val heart = -314 to 314 map { i =>
val t = i / 100.0
val x = 16 * pow(sin(t), 3)
val y = 13 * cos(t) - 5 * cos(2*t) - 2 * cos(3*t) - cos(4*t)
Array(x, y)
}
show(line(heart.toArray, color = RED))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment