Scalala 绘图:编译错误

发布于 2024-11-08 11:22:37 字数 1044 浏览 4 评论 0原文

我正在尝试实现这个问题的答案:https://stackoverflow.com/questions/3704647/can-您推荐一个用于 scala 的图表库/3704974#3704974

我已从 git hub 下载并编译了 Scalala,并将 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< /code> 是 Plotting 的成员。

I'm trying to implement the answer to this question: https://stackoverflow.com/questions/3704647/can-you-recommend-a-charting-library-for-scala/3704974#3704974

I've downloaded and compiled Scalala from the git hub and placed the scalala_2.8.1-1.0.0.RC2-SNAPSHOT.jar in my lib folder (I'm using SBT to do my build). Here's the code:

import scalala.library.Plotting
object ScalalaTest extends Application
{

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

I'm getting the following error:

[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

It looks like my scala compiler recognizes the scalala package but doesn't recognize members of Plotting (I've tried others besides linspace). This is strange because according to the Scalala API, linspace is a member of Plotting.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沙与沫 2024-11-15 11:22:37

这曾经有效,而且很好很优雅 - 似乎当前方式是:

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"

That used to work and was nice and elegant - it seems the current way is:

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")

This needs includes:

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

The SBT dependencies are:

  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"
橪书 2024-11-15 11:22:37

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

linspace seems to be a member of the trait Plotting, not of the companion object. So you'll have to create an instance of Plotting (or anything with Plotting) in order to access that method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文