gonum / gonum/plot

Feature Request: Easy way to cycle through colors

Open
#223 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
3k
Forks
201
PR merge metrics
No merged PRs in 30d

Description

It's a very common desire to have the lines in a plot have different colors. This is not too difficult to accomplish if there are a small number of lines added in one place, but if there are a series of operations that each add to the plot (say, plot is passed along a channel to different cases) it's hard to write each module so that it can add a unique color without caring where it is in the chain.

The easiest design from the perspective of a user is that plot would have a "ColorIterator"

```
type ColorIterator interface {
NextColor() color.RGBA
}
```

This would then be embedded by plot and set to a default iterator with plot.New. A subroutine could then choose the color of a line (for example) with a call to p.NextColor().

I don't know if this is the best design with respect to the rest of the package, some design along those lines would be very nice.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.