2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,7 +1,9 @@
|
|||
Plot a function represented as `x', `y' numerical arrays.
|
||||
;Task:
|
||||
Plot a function represented as `x', `y' numerical arrays.
|
||||
|
||||
Post link to your resulting image for input arrays (see [[Query Performance|'''Example''' section for Python language on ''Query Performance'' page]]):
|
||||
Post the resulting image for the following input arrays (taken from [[Time_a_function#Python|Python's Example section on ''Time a function'']]):
|
||||
x = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
y = {2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0};
|
||||
|
||||
This task is intended as a subtask for [[Measure relative performance of sorting algorithms implementations]].
|
||||
<br><br>
|
||||
|
|
|
|||
32
Task/Plot-coordinate-pairs/Go/plot-coordinate-pairs-2.go
Normal file
32
Task/Plot-coordinate-pairs/Go/plot-coordinate-pairs-2.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/gonum/plot"
|
||||
"github.com/gonum/plot/plotter"
|
||||
"github.com/gonum/plot/plotutil"
|
||||
"github.com/gonum/plot/vg"
|
||||
)
|
||||
|
||||
var (
|
||||
x = []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||
y = []float64{2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0}
|
||||
)
|
||||
|
||||
func main() {
|
||||
pts := make(plotter.XYs, len(x))
|
||||
for i, xi := range x {
|
||||
pts[i] = struct{ X, Y float64 }{float64(xi), y[i]}
|
||||
}
|
||||
p, err := plot.New()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err = plotutil.AddScatters(p, pts); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := p.Save(3*vg.Inch, 3*vg.Inch, "points.svg"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue