Skip to content

plot: y-axis tick label falls off the plot when no plot title #676

Description

@sbinet

probably another glyph-box issue.

with latest master (875edf3), the following code gives:

package main

import (
	"image/color"
	"log"

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

func main() {
	p := plot.New()
	p.X.Min = 0
	p.X.Max = 10
	p.Y.Min = 0
	p.Y.Max = 10

	f1 := plotter.NewFunction(func(x float64) float64 { return 5 })
	f1.LineStyle.Color = color.RGBA{R: 255, A: 255}

	f2 := plotter.NewFunction(func(x float64) float64 { return 6 })
	f2.LineStyle.Color = color.RGBA{B: 255, A: 255}

	p.Add(plotter.NewGlyphBoxes())
	p.Add(f1, f2)
	p.Add(plotter.NewGrid())

	p.Legend.Add("f1", f1)
	p.Legend.Add("f2", f2)
	p.Legend.Top = true

	err := p.Save(20*vg.Centimeter, 15*vg.Centimeter, "box.png")
	if err != nil {
		log.Fatalf("error: %+v", err)
	}
}

box

while with v0.8.1 gives:

box-ref

(notice how the text is chopped off for tick 10 on the y-axis. the f1 legend label as well.)

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