Now that we've finished with getting the file and parsing it, let's plot the data. Again, as in Chapter 2, Linear Regression-House Price Prediction,we will be using Gonum's excellent plotting library. This time around, we're going to be exploring more of it in detail. We'll learn the following:
- How to plot a time series
- How a plot breaks down into its elements and how we can manipulate those elements to style a chart
- How to create plotters for chart types that Gonum does not provide for
We'll start by writing a function to plot a time series:
func newTSPlot(xs []time.Time, ys []float64, seriesName string) *plot.Plot { p, err := plot.New() dieIfErr(err) xys := make(plotter.XYs, len(ys)) for i := range ys { xys[i].X = float64(xs[i].Unix()) ...