Skip to content

Commit

Permalink
Respond to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ctessum committed Apr 30, 2017
1 parent 6d06384 commit e25ebac
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
8 changes: 4 additions & 4 deletions plotter/heat_test.go
Expand Up @@ -49,8 +49,8 @@ func ExampleHeatMap() {
5, 6, 7, 8,
9, 10, 11, 12,
})}
plte := palette.Heat(12, 1)
h := NewHeatMap(m, plte)
pal := palette.Heat(12, 1)
h := NewHeatMap(m, pal)

p, err := plot.New()
if err != nil {
Expand All @@ -62,7 +62,7 @@ func ExampleHeatMap() {

// Create a legend.
rng := h.Max - h.Min
thumbs := PaletteThumbnailers(plte)
thumbs := PaletteThumbnailers(pal)
for i := len(thumbs) - 1; i >= 0; i-- {
t := thumbs[i]
fmin := float64(i) / float64(len(thumbs))
Expand All @@ -75,7 +75,7 @@ func ExampleHeatMap() {
p.X.Max = 1.5
p.Y.Max = 1.5

err = p.Save(100, 100, "testdata/heatMap.png")
err = p.Save(250, 200, "testdata/heatMap.png")
if err != nil {
log.Panic(err)
}
Expand Down
28 changes: 2 additions & 26 deletions plotter/palettethumbnailer.go
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/gonum/plot/vg/draw"
)

// PaletteThumbnailers creates a group of objects that can be used to
// PaletteThumbnailers creates a slice of plot.Thumbnailers that can be used to
// add legend entries for the colors in a color palette.
func PaletteThumbnailers(p palette.Palette) []plot.Thumbnailer {
colors := p.Colors()
Expand All @@ -30,16 +30,8 @@ type paletteThumbnailer struct {
color color.Color
}

// Thumbnail fulfills the plot.Thumbnailer interface.
// Thumbnail satisfies the plot.Thumbnailer interface.
func (t paletteThumbnailer) Thumbnail(c *draw.Canvas) {
lineStyle := draw.LineStyle{
Color: color.Black,
Width: vg.Points(1),
Dashes: []vg.Length{},
DashOffs: 0,
}

// Here we draw the fill.
pts := []vg.Point{
{X: c.Min.X, Y: c.Min.Y},
{X: c.Min.X, Y: c.Max.Y},
Expand All @@ -48,20 +40,4 @@ func (t paletteThumbnailer) Thumbnail(c *draw.Canvas) {
}
poly := c.ClipPolygonY(pts)
c.FillPolygon(t.color, poly)

// Here we draw the upper border.
pts = []vg.Point{
{X: c.Min.X, Y: c.Max.Y},
{X: c.Max.X, Y: c.Max.Y},
}
outline := c.ClipLinesY(pts)
c.StrokeLines(lineStyle, outline...)

// Here we draw the lower border.
pts = []vg.Point{
{X: c.Min.X, Y: c.Min.Y},
{X: c.Max.X, Y: c.Min.Y},
}
outline = c.ClipLinesY(pts)
c.StrokeLines(lineStyle, outline...)
}
Binary file modified plotter/testdata/heatMap_golden.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e25ebac

Please sign in to comment.