func TestHeatMapWithContour(t *testing.T) { if !*visualDebug { return } m := unitGrid{mat64.NewDense(3, 4, []float64{ 2, 1, 4, 3, 6, 7, 2, 5, 9, 10, 11, 12, })} h := NewHeatMap(m, palette.Heat(12, 1)) levels := []float64{1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5} c := NewContour(m, levels, palette.Rainbow(10, palette.Blue, palette.Red, 1, 1, 1)) c.LineStyles[0].Width *= 5 plt, _ := plot.New() plt.Add(h) plt.Add(c) plt.Add(NewGlyphBoxes()) plt.X.Padding = 0 plt.Y.Padding = 0 plt.X.Max = 3.5 plt.Y.Max = 2.5 plt.Save(7, 7, "heat.svg") }
func main() { var levels []float64 for l := 100.5; l < volcano.Matrix.(*mat64.Dense).Max(); l += 5 { levels = append(levels, l) } c := plotter.NewContour(volcano, levels, palette.Rainbow(len(levels), (palette.Yellow+palette.Red)/2, palette.Blue, 1, 1, 1)) quarterStyle := draw.LineStyle{ Color: color.Black, Width: vg.Points(0.5), Dashes: []vg.Length{0.2, 0.4}, } halfStyle := draw.LineStyle{ Color: color.Black, Width: vg.Points(0.5), Dashes: []vg.Length{5, 2, 1, 2}, } c.LineStyles = append(c.LineStyles, quarterStyle, halfStyle, quarterStyle) h := plotter.NewHeatMap(volcano, palette.Heat(len(levels)*2, 1)) p, err := plot.New() if err != nil { panic(err) } p.Title.Text = "Maunga Whau Volcano" p.Add(h) p.Add(c) p.X.Padding = 0 p.Y.Padding = 0 _, p.X.Max, _, p.Y.Max = h.DataRange() name := "example_volcano" for _, ext := range []string{ ".eps", ".pdf", ".svg", ".png", ".tiff", ".jpg", } { if err := p.Save(4, 4, name+ext); err != nil { panic(err) } } }
func Example_heatMap() *plot.Plot { m := unitGrid{mat64.NewDense(3, 4, []float64{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, })} h := plotter.NewHeatMap(m, palette.Heat(12, 1)) p, err := plot.New() if err != nil { panic(err) } p.Title.Text = "Heat map" p.Add(h) p.X.Padding = 0 p.Y.Padding = 0 p.X.Max = 3.5 p.Y.Max = 2.5 return p }