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 h开发者_如何学运维ub 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
.
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"
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.
精彩评论