Skip to content

Commit

Permalink
plot,plotter: introduce new NewLegend
Browse files Browse the repository at this point in the history
  • Loading branch information
sbinet committed Feb 12, 2021
1 parent e331c55 commit 30748ca
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
7 changes: 3 additions & 4 deletions legend.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ type Thumbnailer interface {
Thumbnail(c *draw.Canvas)
}

// NewLegend returns a legend with the default
// parameter settings.
func NewLegend() (Legend, error) {
return newLegend(DefaultTextHandler), nil
// NewLegend returns a legend with the default parameter settings.
func NewLegend() Legend {
return newLegend(DefaultTextHandler)
}

func newLegend(hdlr text.Handler) Legend {
Expand Down
6 changes: 2 additions & 4 deletions legend_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ func ExampleLegend_standalone() {
green := exampleThumbnailer{Color: color.NRGBA{G: 255, A: 255}}
blue := exampleThumbnailer{Color: color.NRGBA{B: 255, A: 255}}

l, err := plot.NewLegend()
if err != nil {
panic(err)
}
l := plot.NewLegend()
l.Add("red", red)
l.Add("green", green)
l.Add("blue", blue)
Expand Down Expand Up @@ -90,6 +87,7 @@ func ExampleLegend_standalone() {
panic(err)
}
defer w.Close()

png := vgimg.PngCanvas{Canvas: c}
if _, err := png.WriteTo(w); err != nil {
panic(err)
Expand Down
5 changes: 1 addition & 4 deletions plotter/heat_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ func ExampleHeatMap() {
p.Add(h)

// Create a legend.
l, err := plot.NewLegend()
if err != nil {
log.Panic(err)
}
l := plot.NewLegend()
thumbs := plotter.PaletteThumbnailers(pal)
for i := len(thumbs) - 1; i >= 0; i-- {
t := thumbs[i]
Expand Down

0 comments on commit 30748ca

Please sign in to comment.