plotutil 3rd dashed line only partially renders at certain resolutions
Created by: dskinner
I found this result rather confusing a few weeks back thinking I had incomplete data until I discovered it was the plot itself. Here's a sample program and plot of the result
package main
import (
"log"
"math"
"github.com/gonum/plot"
"github.com/gonum/plot/plotter"
"github.com/gonum/plot/plotutil"
)
func xyer(out []float64) plotter.XYs {
n := len(out)
xys := make(plotter.XYs, n)
for i, v := range out {
xys[i].X = float64(i) / float64(n)
xys[i].Y = v
}
return xys
}
func decay() []float64 {
sig := make([]float64, 1024)
n := float64(len(sig))
for i := 0.0; i < n; i++ {
sig[int(i)] = math.Exp(2 * math.Pi * -(i / n))
}
return sig
}
func main() {
plt, err := plot.New()
if err != nil {
log.Fatal(err)
}
plt.X.Min, plt.X.Max = 0, 1
plt.Y.Min, plt.Y.Max = -1, 1
empty := make([]float64, 1024)
plotutil.AddLines(plt,
"empty", xyer(empty),
"empty", xyer(empty), // comment out and decay plots ok
"decay", xyer(decay()), // this dashed line is bugged
)
plt.Save(1000, 500, "out.png")
// Increase size and decay plots ok
// plt.Save(2000, 1000, "out.png")
}