Thanks to visit codestin.com
Credit goes to github.com

Skip to content

plot: Plot renders outside of image bounds #761

@mlange-42

Description

@mlange-42

What are you trying to do?

Just trying to make a simple line plot. However, depending on the axis limits, the rendered plot does not fit onto the image and exceeds its bounds.

What did you do?

Minimal reproducing example:

package main

import (
	"math/rand"

	"gonum.org/v1/plot"
	"gonum.org/v1/plot/plotter"
)

func main() {
	p := plot.New()

	p.Legend = plot.NewLegend()

	length := 70
	xy := make(plotter.XYs, length)
	for i := 0; i < length; i++ {
		xy[i] = plotter.XY{X: float64(i), Y: rand.Float64()}
	}

	lines, err := plotter.NewLine(xy)
	if err != nil {
		panic(err)
	}

	p.Add(lines)
	p.Legend.Add("Legend entry", lines)

	p.Save(600, 400, "test.png")
}

What did you expect to happen?

The plot nicely fills the image.

What actually happened?

The plot is partially outside the image bounds:

test

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

go version go1.20 windows/amd64
plot vrsion v0.12.0

Does this issue reproduce with the current master?

Yes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions