gonum / plot

A repository for plotting and visualizing data
BSD 3-Clause "New" or "Revised" License
2.74k stars 203 forks source link

Define types plotter.XY and plotter.XYZ for append #494

Closed chmike closed 5 years ago

chmike commented 5 years ago

What are you trying to do?

Creating a plotter.XYs value by appending its points with append because the total number of points is unknown when I start.

What did you do?

points := make(plotter.XYs, 0, 1024)
for {
    ...
    points = append(points, struct{ X, Y float64 }{x, y})
}

What did you expect to happen?

I expect I could write the following which is more readable and intuitive.

points = append(points, plotter.XY{x, y})

What version of Go and Gonum/plot are you using?

Current

Does this issue reproduce with the current master?

Yes

kortschak commented 5 years ago

This seems like a reasonable expectation.

sbinet commented 5 years ago

@chmike do you want to give this a stab and send your first PR against the Gonum repo? :)