1

次のBreezeの使用例を理解するのに役立ちます。f.subplot(0)以下のコードには、などのScalaオブジェクトメソッドの呼び出しと、関数呼び出しの両方が含まf.saveasれています。 linspace(0.0,1.0)plot(x, x :^ 2.0)

いつものように、オブジェクトメソッドは生成されたドキュメントで説明されています:http ://www.scalanlp.org/api/index.html#breeze.plot.Plot

質問:

1)関数呼び出しの仕様はどこにありますか:linspace(0.0,1.0)plot(x, x :^ 2.0)?私が知っている限り、BreezeはJFreeChart(http://www.jfree.org/jfreechart/download.html)を使用しています。たぶんこれらlinspaceplotJavaオブジェクトはJFreeChartパッケージからインポートされていますか?

2)どういうx :^ 3.0意味ですか?

import breeze.plot._

val f = Figure()
val p = f.subplot(0)
val x = linspace(0.0,1.0)
p += plot(x, x :^ 2.0)
p += plot(x, x :^ 3.0, '.')
p.xlabel = "x axis"
p.ylabel = "y axis"
f.saveas("lines.png") // save current figure as a .png, eps and pdf also supported
4

1 に答える 1

0

1linspace仕様は、breezeパッケージオブジェクトlinalgにありplot、パッケージオブジェクトにありますplog

http://www.scalanlp.org/api/index.html#breeze.linalg.package https://github.com/scalanlp/breeze/blob/master/math/src/main/scala/breeze/linalg/package .scala#L127

  /**
   * Generates a vector of linearly spaced values between a and b (inclusive).
   * The returned vector will have length elements, defaulting to 100.
   */
  def linspace(a : Double, b : Double, length : Int = 100) : DenseVector[Double] = {
    val increment = (b - a) / (length - 1)
    DenseVector.tabulate(length)(i => a + increment * i)
  }

http://www.scalanlp.org/api/index.html#breeze.plot.package https://github.com/scalanlp/breeze/blob/master/viz/src/main/scala/breeze/plot/package .scala#L24

  /**
   * Plots the given y versus the given x with the given style.
   *
   * @param x X-coordinates, co-indexed with y (and indexed by keys of type K).
   * @param y Y-coordinates, co-indexed with x (and indexed by keys of type K).
   * @param style Matlab-like style spec of the series to plot.
   * @param name Name of the series to show in the legend.
   * @param labels Optional in-graph labels for some points.
   * @param tips Optional mouse-over tooltips for some points.
   */
  def plot[X,Y,V](x: X, y: Y, style : Char = '-', colorcode : String = null, name : String = null,
                  lines : Boolean = true, shapes : Boolean = false,
                  labels : (Int) => String = null.asInstanceOf[Int=>String],
                  tips : (Int) => String = null.asInstanceOf[Int=>String] )
                 (implicit xv: DomainFunction[X,Int,V],
                  yv: DomainFunction[Y, Int, V], vv: V=>Double):Series = new Series {
    ...

2これは要素ごとのべき乗です。したがってx :^ 3.0、すべての要素でxを3乗します。与えられた例では、xはDenseVector0から1までの100の値です。したがって、 0から1までの100の値x :^ 3.0がもう1つ得られますDenseVectorが、これらは3乗され、優れたグラフになります。

于 2013-03-25T18:31:01.350 に答える