zhanglong2005 / plotinum

Automatically exported from code.google.com/p/plotinum
MIT License
0 stars 0 forks source link

Default tick marks should be more "balanced" #114

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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
}

Original issue reported on code.google.com by burns.ethan@gmail.com on 20 Feb 2013 at 7:08

GoogleCodeExporter commented 9 years ago
Hopefully someone else wants to play with this.

Original comment by burns.ethan@gmail.com on 20 Feb 2013 at 7:09