Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default tick marks should be more "balanced" #141

Open
eaburns opened this issue Mar 15, 2015 · 1 comment
Open

Default tick marks should be more "balanced" #141

eaburns opened this issue Mar 15, 2015 · 1 comment

Comments

@eaburns
Copy link
Member

eaburns commented Mar 15, 2015

Original issue 114 created by eaburns on 2013-02-20T19:08:16.000Z:

In the plot below, the tick marks are "top heavy" (or "right heavy" if you consider the X axis). If the major and minor ticks were swapped then the major tick marks would look more balanced. It may be easy to get more balanced ticks by looking at the mean value of the major ticks and comparing it to the center of the axis. The closer the mean is to the center, the more balanced the ticks are.

package main

import (
    "code.google.com/p/plotinum/plot"
    "code.google.com/p/plotinum/plotter"
    "code.google.com/p/plotinum/plotutil"
)

var (
    newSched = speedup{
        { 1, 23.857 },
        { 2, 12.183 },
        { 4, 6.557 },
        { 8, 4.338 },
        { 16, 3.478 },
        { 32, 2.385 },
    }
    oldSched = speedup{
        { 1, 23.163},
        { 2, 22.182},
        { 4, 25.568 },
        { 8, 31.372},
        { 16, 27.275 },
        { 32,26.074 },
    }
)

func main() {
    p, err := plot.New()
    if err != nil {
        panic(err)
    }
    plotutil.AddLinePoints(p, "new", newSched, "old", oldSched)
    p.Add(plotter.NewFunction(func(x float64)float64{ return x }))

    p.Title.Text = "Speedup of schedulers"
    p.X.Label.Text = "proc"
    p.Y.Label.Text = "speedup (of real time)"
    p.Legend.Top = true
    p.Legend.Left = true
    p.Y.Max = 32
    p.Save(4, 4, "speedup.svg")
}

type speedup plotter.XYs

func (s speedup) Len() int {
    return plotter.XYs(s).Len()
}

func (s speedup) XY(i int) (float64, float64) {
    x, y := plotter.XYs(s).XY(i)
    _, y0 := plotter.XYs(s).XY(0)
    return x, y0/y
}
@eaburns
Copy link
Member Author

eaburns commented Mar 15, 2015

Comment #1 originally posted by eaburns on 2013-02-20T19:09:07.000Z:

Hopefully someone else wants to play with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant