Last active
April 2, 2018 11:24
-
-
Save cipepser/31d1820b58d1a4c7cf8d9d2e0013e515 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/cipepser/plot/plotter" | |
"gonum.org/v1/plot" | |
"gonum.org/v1/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