Last active
June 15, 2024 07:58
-
-
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/742edfe0002ee6a9cf7d5ea0a96959df09757b0b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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.4.2" | |
//> using dep "com.github.haifengl::smile-scala:3.1.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.* | |
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