2

我正在尝试回答这个问题:https ://stackoverflow.com/questions/3704647/can-you-recommend-a-charting-library-for-scala/3704974#3704974

我已经Scalala从 git hub 下载并编译并将其放在scalala_2.8.1-1.0.0.RC2-SNAPSHOT.jar我的lib文件夹中(我正在使用 SBT 进行构建)。这是代码:

import scalala.library.Plotting
object ScalalaTest extends Application
{

  val x = Plotting.linspace(0,1);
}

我收到以下错误:

[error] /src/main/scala/ScalalaTest.scala:6: value linspace is not a member of object scalala.library.Plotting
[error]   val x = Plotting.linspace(0,1);
[error]                    ^
[error] one error found

看起来我的 scala 编译器识别scalala包但不识别成员Plotting(我已经尝试过除此之外的其他包linspace)。这很奇怪,因为根据Scalala APIlinspace它是Plotting.

4

2 回答 2

2

以前可以工作,而且很好很优雅-目前的方式似乎是:

val x = DenseVector.range(0,100) / 100.0;
plot.hold = true
plot(x, x :^ 2)
plot(x, x :^ 3, '.')
xlabel("x axis")
ylabel("y axis")
saveas("lines.png")

这种需求包括:

import scalala.tensor.dense.DenseVector
import scalala.library.Plotting._

SBT 依赖项是:

  val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/"
  val ScalaNLPMaven2 = "ScalaNLP Maven2" at "http://repo.scalanlp.org/repo/"
  val ondex = "ondex" at "http://ondex.rothamsted.bbsrc.ac.uk/nexus/content/groups/public/"

  val scalala = "org.scalala" %% "scalala" % "1.0.0.RC2-SNAPSHOT"
于 2011-05-21T22:25:51.493 回答
0

linspace似乎是 trait 的成员Plotting,而不是伴随对象的成员。因此,您必须创建Plotting(或任何with Plotting)的实例才能访问该方法。

于 2011-05-21T05:58:53.640 回答