func PlotLeadFloat(yMin, yMax float64, widthPx, heightPx int, floatVals []float64) (image.Image, error) {
	var chartRange *chart.ContinuousRange

	if yMin != yMax {
		chartRange = &chart.ContinuousRange{Min: yMin, Max: yMax}
	}

	graph := chart.Chart{
		Width:  widthPx,
		Height: heightPx,
		XAxis: chart.XAxis{
			Style: chart.Hidden(),
		},
		YAxis: chart.YAxis{
			Style: chart.Hidden(),
			Range: chartRange,
		},
		Series: []chart.Series{
			chart.ContinuousSeries{
				XValues: intSeq(len(floatVals)),
				YValues: floatVals,
			},
		},
	}

	// Render to a byte buffer
	buffer := bytes.NewBuffer([]byte{})
	if err := graph.Render(chart.PNG, buffer); err != nil {
		return nil, err
	}

	// Fetch the img representation of the graph
	src, _, err := image.Decode(buffer)
	if err != nil {
		return nil, err
	}

	// Create a new grayscale image
	bounds := src.Bounds()
	w, h := bounds.Max.X, bounds.Max.Y
	gray := image.NewGray(image.Rect(0, 0, w, h))
	for x := 0; x < w; x++ {
		for y := 0; y < h; y++ {
			oldColor := src.At(x, y)
			grayColor := color.GrayModel.Convert(oldColor)
			gray.Set(x, y, grayColor)
		}
	}

	return gray, nil
}
// PlotLeadFloat yields a grayscale image
PlotLeadFloat yields a grayscale image
// PlotLeadFloat yields a grayscale image
func PlotLeadFloat(yMin, yMax float64, widthPx, heightPx int, floatVals []float64) (image.Image, error) {
	var chartRange *chart.ContinuousRange
	if yMin != yMax {
		chartRange = &chart.ContinuousRange{Min: yMin, Max: yMax}
	}
	graph := chart.Chart{
		Width:  widthPx,
		Height: heightPx,
		XAxis: chart.XAxis{
			Style: chart.Hidden(),
		},
		YAxis: chart.YAxis{
			Style: chart.Hidden(),
			Range: chartRange,
		},
		Series: []chart.Series{
			chart.ContinuousSeries{
				XValues: intSeq(len(floatVals)),
				YValues: floatVals,
			},
		},
	}
	buffer := bytes.NewBuffer([]byte{})
	if err := graph.Render(chart.PNG, buffer); err != nil {
		return nil, err
	}
	src, _, err := image.Decode(buffer)
	if err != nil {
		return nil, err
	}
	bounds := src.Bounds()
	w, h := bounds.Max.X, bounds.Max.Y
	gray := image.NewGray(image.Rect(0, 0, w, h))
	for x := 0; x < w; x++ {
		for y := 0; y < h; y++ {
			oldColor := src.At(x, y)
			grayColor := color.GrayModel.Convert(oldColor)
			gray.Set(x, y, grayColor)
		}
	}
	return gray, nil
}
func PlotLeadFloat ( yMin , yMax float64 , widthPx , heightPx int , floatVals [ ] float64 ) ( image . Image , error ) { var chartRange * chart . ContinuousRange if yMin != yMax { chartRange = & chart . ContinuousRange { Min : yMin , Max : yMax } } graph := chart . Chart { Width : widthPx , Height : heightPx , XAxis : chart . XAxis { Style : chart . Hidden ( ) , } , YAxis : chart . YAxis { Style : chart . Hidden ( ) , Range : chartRange , } , Series : [ ] chart . Series { chart . ContinuousSeries { XValues : intSeq ( len ( floatVals ) ) , YValues : floatVals , } , } , } buffer := bytes . NewBuffer ( [ ] byte { } ) if err := graph . Render ( chart . PNG , buffer ) ; err != nil { return nil , err } src , _ , err := image . Decode ( buffer ) if err != nil { return nil , err } bounds := src . Bounds ( ) w , h := bounds . Max . X , bounds . Max . Y gray := image . NewGray ( image . Rect ( 0 , 0 , w , h ) ) for x := 0 ; x < w ; x ++ { for y := 0 ; y < h ; y ++ { oldColor := src . At ( x , y ) grayColor := color . GrayModel . Convert ( oldColor ) gray . Set ( x , y , grayColor ) } } return gray , nil }
PlotLeadFloat yields a grayscale image
PlotLeadFloat yields a grayscale image
// Render to a byte buffer // Fetch the img representation of the graph // Create a new grayscale image