Bug in poltnium line plotter?

14 views
Skip to first unread message

Ethan Burns

unread,
Jul 11, 2014, 8:13:09 AM7/11/14
to Steven Wiley, plotinum...@googlegroups.com

Hi Steve,
[+plotinum-discuss]

Thanks for the bug report! This was an ugly bug that snuck in during a recent change. I filed an issue for it: https://code.google.com/p/plotinum/issues/detail?id=143, and submitted a fix. Feel free to include plotinum-discuss on bug reports or any issues that you have in the future, as others may be interested. Also, feel free to add to the issue tracker if you find a bug or have a feature request.

The problem here seems to be that the plotter was drawing the path used to share under the line, but shading was off so the path was empty. This resulted in gibberish. Perhaps the vg package should state that drawing an empty path results in nothing being drawn. This would require the vgimg implementation to be fixed.

By the way, this is just the type of bug that unit testing would've caught, if anyone is interested in implementing some. I don't have time at the moment.

Ethan


On Fri, Jul 11, 2014, 00:05 Steven Wiley <steven...@gmail.com> wrote:
Hi Ethan,

I am a golang fanboy, and I just downloaded and started using plotnium. First I installed the package using go get from github as prescribed, (go get code.google.com/p/plotinum/...). Then I tried running the first example file and the result is the attached plot, badplot.png. 

After looking at the source code for a few minutes, I traced the aberrant lines to line 68 of the line.go file in the plotter package. My cursory inspection leaves me wondering why minY needs to be calculated here, since if I remove it altogether I get the results shown in goodplot.png. 

Here are the changes I made to fix the apparent bug, lines 50 through 68


//minY := trY(plt.Y.Min)
    var pa vg.Path

    for i, p := range pts.XYs {
        ps[i].X = trX(p.X)
        ps[i].Y = trY(p.Y)

        if pts.ShadeColor == nil {
            continue
        }

        //if i == 0 {
        //    pa.Move(ps[i].X, minY)
        //}

        pa.Line(ps[i].X, ps[i].Y)
    }

    //pa.Line(ps[len(pts.XYs)-1].X, minY)

All of the commented out lines were my modifications. 

Doing this also achieves the same result, but I guess is more logical/readable

        if i == 0 {
            pa.Move(ps[i].X, ps[i].Y)
        } else {
            pa.Line(ps[i].X, ps[i].Y)
        }


The package looks really nice overall, Ethan. The fact that in a few minutes I could trace down the source of the bug has to do with the organized nature of the package. However, you can imagine my initial disappointment with that nasty slash running across the result of the offered example code!

I was not sure if contacting you directly was better than posting this to the plotonium-discuss group, so I thought I would leave that to your discretion.

kind regards,
Steven Wiley




Reply all
Reply to author
Forward
0 new messages