Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
package main
import (
"github.com/cipepser/plot/plotter"
"github.com/gonum/plot"
"github.com/gonum/plot/vg"
)
func main() {
// 描画するデータ
data := [][]float64{
{1, 0.7, 2, 1.5},
{1.2, 1.3, 1.2, 0.8, 1.1, 1},
{0.8, 0.5, 1.3},
{1.1, 1, 3, 2.5},
{2.2, 2, 4, 3.5},
{3, 3.9, 3.8},
{3.7, 4.1, 3.6, 4},
{3.9, 0.8, 1.5},
{1.3, 1.2, 2.3},
{2.2, 2.1, 2.4, 1.8, 2},
{2.1, 3, 2, 1.5, 2.2, 2.2, 2.5},
{2.3, 2.2, 2.5, 2.2},
}
p, err := plot.New()
if err != nil {
panic(err)
}
cc, err := plotter.NewCandleChart(data)
if err != nil {
panic(err)
}
p.Add(cc)
// グラフの整形
p.Title.Text = "CandleStick Chart"
p.X.Label.Text = "Time"
p.X.Min = -0.5
p.X.Max = float64(len(data)) * 1.1
// 保存
file := "img.png"
if err = p.Save(10*vg.Inch, 6*vg.Inch, file); err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment