ループを使用して複数のプロットを追加しようとしていますが、行を挿入する方法がわかりません。私が作業しているコードは次のとおりです。Gonumプロットループスルースライス
func plot_stochastic_processes(processes [][]float64, title string) {
p, err := plot.New()
if err != nil {
panic(err)
}
p.Title.Text = title
p.X.Label.Text = "X"
p.Y.Label.Text = "Y"
err = plotutil.AddLinePoints(p,
"Test", getPoints(processes[1]),
//Need to figure out how to loop through processes
)
if err != nil {
panic(err)
}
// Save the plot to a PNG file.
if err := p.Save(4*vg.Inch, 4*vg.Inch, "points.png"); err != nil {
panic(err)
}
}
マイgetPoints機能は次のようになります。
func getPoints(line []float64) plotter.XYs {
pts := make(plotter.XYs, len(line))
for j, k := range line {
pts[j].X = float64(j)
pts[j].Y = k
}
return pts
}
コメントセクションがあるループを入れしようとしたとき、私はエラーを取得します。これはかなり簡単であるはずです。おそらくこれの前にループのリストを取得するループですか?明らかに
for i, process := range processes {
return "title", getPoints(process),
}
よう
何かが、私はそれが正しくないですけど、私はそれについて移動するかどうかはわかりませんではありません。
どのようなインターフェイスのplotutil.AddLinePoints?可変機能? 'plotutil.AddLinePoints(p、 " Test "、getPoints(processes [1])...)のように渡します。 – mattn
Variadic。私は技術的にそれらを必要としないので、私はタイトルを削除することができます。 – user8244734