本文整理汇总了Golang中github.com/sksullivan/plot/vg.Points函数的典型用法代码示例。如果您正苦于以下问题:Golang Points函数的具体用法?Golang Points怎么用?Golang Points使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Points函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Example_groupedHorizontalBoxPlots
// Example_groupedHorizontalBoxPlots draws vertical boxplots.
func Example_groupedHorizontalBoxPlots() *plot.Plot {
rand.Seed(int64(0))
n := 100
uniform := make(plotter.Values, n)
normal := make(plotter.Values, n)
expon := make(plotter.Values, n)
for i := 0; i < n; i++ {
uniform[i] = rand.Float64()
normal[i] = rand.NormFloat64()
expon[i] = rand.ExpFloat64()
}
p, err := plot.New()
if err != nil {
panic(err)
}
p.Title.Text = "Box Plot"
p.Y.Label.Text = "plotter.Values"
w := vg.Points(20)
for y := 0.0; y < 3.0; y++ {
b0 := must(plotter.MakeHorizBoxPlot(w, y, uniform)).(plotter.HorizBoxPlot)
b0.Offset = -w - vg.Points(3)
b1 := must(plotter.MakeHorizBoxPlot(w, y, normal)).(plotter.HorizBoxPlot)
b2 := must(plotter.MakeHorizBoxPlot(w, y, expon)).(plotter.HorizBoxPlot)
b2.Offset = w + vg.Points(3)
p.Add(b0, b1, b2)
}
p.NominalY("Group 0", "Group 1", "Group 2")
return p
}
开发者ID:sksullivan,项目名称:plot,代码行数:32,代码来源:main.go
示例2: Example_groupedBoxPlots
// Example_groupedBoxPlots draws vertical boxplots.
func Example_groupedBoxPlots() *plot.Plot {
rand.Seed(int64(0))
n := 100
uniform := make(plotter.Values, n)
normal := make(plotter.Values, n)
expon := make(plotter.Values, n)
for i := 0; i < n; i++ {
uniform[i] = rand.Float64()
normal[i] = rand.NormFloat64()
expon[i] = rand.ExpFloat64()
}
p, err := plot.New()
if err != nil {
panic(err)
}
p.Title.Text = "Box Plot"
p.Y.Label.Text = "plotter.Values"
w := vg.Points(20)
for x := 0.0; x < 3.0; x++ {
b0 := must(plotter.NewBoxPlot(w, x, uniform)).(*plotter.BoxPlot)
b0.Offset = -w - vg.Points(3)
b1 := must(plotter.NewBoxPlot(w, x, normal)).(*plotter.BoxPlot)
b2 := must(plotter.NewBoxPlot(w, x, expon)).(*plotter.BoxPlot)
b2.Offset = w + vg.Points(3)
p.Add(b0, b1, b2)
}
// Set the X axis of the plot to nominal with
// the given names for x=0, x=1 and x=2.
p.NominalX("Group 0", "Group 1", "Group 2")
return p
}
开发者ID:sksullivan,项目名称:plot,代码行数:35,代码来源:main.go
示例3: Example_logo
// Draw the plotinum logo.
func Example_logo() *plot.Plot {
p, err := plot.New()
if err != nil {
panic(err)
}
plotter.DefaultLineStyle.Width = vg.Points(1)
plotter.DefaultGlyphStyle.Radius = vg.Points(3)
p.Y.Tick.Marker = plot.ConstantTicks([]plot.Tick{
{0, "0"}, {0.25, ""}, {0.5, "0.5"}, {0.75, ""}, {1, "1"},
})
p.X.Tick.Marker = plot.ConstantTicks([]plot.Tick{
{0, "0"}, {0.25, ""}, {0.5, "0.5"}, {0.75, ""}, {1, "1"},
})
pts := plotter.XYs{{0, 0}, {0, 1}, {0.5, 1}, {0.5, 0.6}, {0, 0.6}}
line := must(plotter.NewLine(pts)).(*plotter.Line)
scatter := must(plotter.NewScatter(pts)).(*plotter.Scatter)
p.Add(line, scatter)
pts = plotter.XYs{{1, 0}, {0.75, 0}, {0.75, 0.75}}
line = must(plotter.NewLine(pts)).(*plotter.Line)
scatter = must(plotter.NewScatter(pts)).(*plotter.Scatter)
p.Add(line, scatter)
pts = plotter.XYs{{0.5, 0.5}, {1, 0.5}}
line = must(plotter.NewLine(pts)).(*plotter.Line)
scatter = must(plotter.NewScatter(pts)).(*plotter.Scatter)
p.Add(line, scatter)
return p
}
开发者ID:sksullivan,项目名称:plot,代码行数:34,代码来源:main.go
示例4: NewBoxPlot
// NewBoxPlot returns a new BoxPlot that represents
// the distribution of the given values. The style of
// the box plot is that used for Tukey's schematic
// plots is ``Exploratory Data Analysis.''
//
// An error is returned if the boxplot is created with
// no values.
//
// The fence values are 1.5x the interquartile before
// the first quartile and after the third quartile. Any
// value that is outside of the fences are drawn as
// Outside points. The adjacent values (to which the
// whiskers stretch) are the minimum and maximum
// values that are not outside the fences.
func NewBoxPlot(w vg.Length, loc float64, values Valuer) (*BoxPlot, error) {
if w < 0 {
return nil, errors.New("Negative boxplot width")
}
b := new(BoxPlot)
var err error
if b.fiveStatPlot, err = newFiveStat(w, loc, values); err != nil {
return nil, err
}
b.Width = w
b.CapWidth = 3 * w / 4
b.GlyphStyle = DefaultGlyphStyle
b.BoxStyle = DefaultLineStyle
b.MedianStyle = DefaultLineStyle
b.WhiskerStyle = draw.LineStyle{
Width: vg.Points(0.5),
Dashes: []vg.Length{vg.Points(4), vg.Points(2)},
}
if len(b.Values) == 0 {
b.Width = 0
b.GlyphStyle.Radius = 0
b.BoxStyle.Width = 0
b.MedianStyle.Width = 0
b.WhiskerStyle.Width = 0
}
return b, nil
}
开发者ID:sksullivan,项目名称:plot,代码行数:46,代码来源:boxplot.go
示例5: Example_boxPlots
// Example_boxPlots draws vertical boxplots.
func Example_boxPlots() *plot.Plot {
rand.Seed(int64(0))
n := 100
uniform := make(plotter.Values, n)
normal := make(plotter.Values, n)
expon := make(plotter.Values, n)
for i := 0; i < n; i++ {
uniform[i] = rand.Float64()
normal[i] = rand.NormFloat64()
expon[i] = rand.ExpFloat64()
}
p, err := plot.New()
if err != nil {
panic(err)
}
p.Title.Text = "Box Plot"
p.Y.Label.Text = "plotter.Values"
// Make boxes for our data and add them to the plot.
p.Add(must(plotter.NewBoxPlot(vg.Points(20), 0, uniform)).(*plotter.BoxPlot),
must(plotter.NewBoxPlot(vg.Points(20), 1, normal)).(*plotter.BoxPlot),
must(plotter.NewBoxPlot(vg.Points(20), 2, expon)).(*plotter.BoxPlot))
// Set the X axis of the plot to nominal with
// the given names for x=0, x=1 and x=2.
p.NominalX("Uniform\nDistribution", "Normal\nDistribution",
"Exponential\nDistribution")
return p
}
开发者ID:sksullivan,项目名称:plot,代码行数:31,代码来源:main.go
示例6: makeLegend
// makeLegend returns a legend with the default
// parameter settings.
func makeLegend() (Legend, error) {
font, err := vg.MakeFont(DefaultFont, vg.Points(12))
if err != nil {
return Legend{}, err
}
return Legend{
ThumbnailWidth: vg.Points(20),
TextStyle: draw.TextStyle{Font: font},
}, nil
}
开发者ID:sksullivan,项目名称:plot,代码行数:12,代码来源:legend.go
示例7: Example_horizontalBoxPlots
// Example_horizontalBoxPlots draws horizontal boxplots
// with some labels on their points.
func Example_horizontalBoxPlots() *plot.Plot {
rand.Seed(int64(0))
n := 100
uniform := make(valueLabels, n)
normal := make(valueLabels, n)
expon := make(valueLabels, n)
for i := 0; i < n; i++ {
uniform[i].Value = rand.Float64()
uniform[i].Label = fmt.Sprintf("%4.4f", uniform[i].Value)
normal[i].Value = rand.NormFloat64()
normal[i].Label = fmt.Sprintf("%4.4f", normal[i].Value)
expon[i].Value = rand.ExpFloat64()
expon[i].Label = fmt.Sprintf("%4.4f", expon[i].Value)
}
p, err := plot.New()
if err != nil {
panic(err)
}
p.Title.Text = "Horizontal Box Plot"
p.X.Label.Text = "plotter.Values"
// Make boxes for our data and add them to the plot.
uniBox := must(plotter.MakeHorizBoxPlot(vg.Points(20), 0, uniform)).(plotter.HorizBoxPlot)
uniLabels, err := uniBox.OutsideLabels(uniform)
if err != nil {
panic(err)
}
normBox := must(plotter.MakeHorizBoxPlot(vg.Points(20), 1, normal)).(plotter.HorizBoxPlot)
normLabels, err := normBox.OutsideLabels(normal)
if err != nil {
panic(err)
}
expBox := must(plotter.MakeHorizBoxPlot(vg.Points(20), 2, expon)).(plotter.HorizBoxPlot)
expLabels, err := expBox.OutsideLabels(expon)
if err != nil {
panic(err)
}
p.Add(uniBox, uniLabels, normBox, normLabels, expBox, expLabels)
// Add a GlyphBox plotter for debugging.
p.Add(plotter.NewGlyphBoxes())
// Set the Y axis of the plot to nominal with
// the given names for y=0, y=1 and y=2.
p.NominalY("Uniform\nDistribution", "Normal\nDistribution",
"Exponential\nDistribution")
return p
}
开发者ID:sksullivan,项目名称:plot,代码行数:53,代码来源:main.go
示例8: main
func main() {
var levels []float64
for l := 100.5; l < volcano.Matrix.(*mat64.Dense).Max(); l += 5 {
levels = append(levels, l)
}
c := plotter.NewContour(volcano, levels, palette.Rainbow(len(levels), (palette.Yellow+palette.Red)/2, palette.Blue, 1, 1, 1))
quarterStyle := draw.LineStyle{
Color: color.Black,
Width: vg.Points(0.5),
Dashes: []vg.Length{0.2, 0.4},
}
halfStyle := draw.LineStyle{
Color: color.Black,
Width: vg.Points(0.5),
Dashes: []vg.Length{5, 2, 1, 2},
}
c.LineStyles = append(c.LineStyles, quarterStyle, halfStyle, quarterStyle)
h := plotter.NewHeatMap(volcano, palette.Heat(len(levels)*2, 1))
p, err := plot.New()
if err != nil {
panic(err)
}
p.Title.Text = "Maunga Whau Volcano"
p.Add(h)
p.Add(c)
p.X.Padding = 0
p.Y.Padding = 0
_, p.X.Max, _, p.Y.Max = h.DataRange()
name := "example_volcano"
for _, ext := range []string{
".eps",
".pdf",
".svg",
".png",
".tiff",
".jpg",
} {
if err := p.Save(4, 4, name+ext); err != nil {
panic(err)
}
}
}
开发者ID:sksullivan,项目名称:plot,代码行数:48,代码来源:volcano_example.go
示例9: Example_groupedQuartPlots
func Example_groupedQuartPlots() *plot.Plot {
rand.Seed(int64(0))
n := 100
uniform := make(plotter.Values, n)
normal := make(plotter.Values, n)
expon := make(plotter.Values, n)
for i := 0; i < n; i++ {
uniform[i] = rand.Float64()
normal[i] = rand.NormFloat64()
expon[i] = rand.ExpFloat64()
}
p, err := plot.New()
if err != nil {
panic(err)
}
p.Title.Text = "Box Plot"
p.Y.Label.Text = "plotter.Values"
w := vg.Points(10)
for x := 0.0; x < 3.0; x++ {
b0 := must(plotter.NewQuartPlot(x, uniform)).(*plotter.QuartPlot)
b0.Offset = -w
b1 := must(plotter.NewQuartPlot(x, normal)).(*plotter.QuartPlot)
b2 := must(plotter.NewQuartPlot(x, expon)).(*plotter.QuartPlot)
b2.Offset = w
p.Add(b0, b1, b2)
}
p.Add(plotter.NewGlyphBoxes())
p.NominalX("Group 0", "Group 1", "Group 2")
return p
}
开发者ID:sksullivan,项目名称:plot,代码行数:33,代码来源:main.go
示例10: Example_histogram
// An example of making a histogram.
func Example_histogram() *plot.Plot {
rand.Seed(int64(0))
n := 10000
vals := make(plotter.Values, n)
for i := 0; i < n; i++ {
vals[i] = rand.NormFloat64()
}
p, err := plot.New()
if err != nil {
panic(err)
}
p.Title.Text = "Histogram"
h, err := plotter.NewHist(vals, 16)
if err != nil {
panic(err)
}
h.Normalize(1)
p.Add(h)
// The normal distribution function
norm := plotter.NewFunction(stdNorm)
norm.Color = color.RGBA{R: 255, A: 255}
norm.Width = vg.Points(2)
p.Add(norm)
return p
}
开发者ID:sksullivan,项目名称:plot,代码行数:29,代码来源:main.go
示例11: DrawGlyph
// DrawGlyph implements the Glyph interface.
func (RingGlyph) DrawGlyph(c *Canvas, sty GlyphStyle, pt Point) {
c.SetLineStyle(LineStyle{Color: sty.Color, Width: vg.Points(0.5)})
var p vg.Path
p.Move(pt.X+sty.Radius, pt.Y)
p.Arc(pt.X, pt.Y, sty.Radius, 0, 2*math.Pi)
p.Close()
c.Stroke(p)
}
开发者ID:sksullivan,项目名称:plot,代码行数:9,代码来源:canvas.go
示例12: Example_points
// Example_points draws some scatter points, a line,
// and a line with points.
func Example_points() *plot.Plot {
rand.Seed(int64(0))
n := 15
scatterData := randomPoints(n)
lineData := randomPoints(n)
linePointsData := randomPoints(n)
p, err := plot.New()
if err != nil {
panic(err)
}
p.Title.Text = "Points Example"
p.X.Label.Text = "X"
p.Y.Label.Text = "Y"
p.Add(plotter.NewGrid())
s := must(plotter.NewScatter(scatterData)).(*plotter.Scatter)
s.GlyphStyle.Color = color.RGBA{R: 255, B: 128, A: 255}
s.GlyphStyle.Radius = vg.Points(3)
l := must(plotter.NewLine(lineData)).(*plotter.Line)
l.LineStyle.Width = vg.Points(1)
l.LineStyle.Dashes = []vg.Length{vg.Points(5), vg.Points(5)}
l.LineStyle.Color = color.RGBA{B: 255, A: 255}
lpLine, lpPoints, err := plotter.NewLinePoints(linePointsData)
if err != nil {
panic(err)
}
lpLine.Color = color.RGBA{G: 255, A: 255}
lpPoints.Shape = draw.CircleGlyph{}
lpPoints.Color = color.RGBA{R: 255, A: 255}
p.Add(s, l, lpLine, lpPoints)
p.Legend.Add("scatter", s)
p.Legend.Add("line", l)
p.Legend.Add("line points", lpLine, lpPoints)
return p
}
开发者ID:sksullivan,项目名称:plot,代码行数:43,代码来源:main.go
示例13: Example_functions
// Example_functions draws some functions.
func Example_functions() *plot.Plot {
p, err := plot.New()
if err != nil {
panic(err)
}
p.Title.Text = "Functions"
p.X.Label.Text = "X"
p.Y.Label.Text = "Y"
quad := plotter.NewFunction(func(x float64) float64 { return x * x })
quad.Color = color.RGBA{B: 255, A: 255}
exp := plotter.NewFunction(func(x float64) float64 { return math.Pow(2, x) })
exp.Dashes = []vg.Length{vg.Points(2), vg.Points(2)}
exp.Width = vg.Points(2)
exp.Color = color.RGBA{G: 255, A: 255}
sin := plotter.NewFunction(func(x float64) float64 { return 10*math.Sin(x) + 50 })
sin.Dashes = []vg.Length{vg.Points(4), vg.Points(5)}
sin.Width = vg.Points(4)
sin.Color = color.RGBA{R: 255, A: 255}
p.Add(quad, exp, sin)
p.Legend.Add("x^2", quad)
p.Legend.Add("2^x", exp)
p.Legend.Add("10*sin(x)+50", sin)
p.Legend.ThumbnailWidth = 0.5 * vg.Inch
p.X.Min = 0
p.X.Max = 10
p.Y.Min = 0
p.Y.Max = 100
return p
}
开发者ID:sksullivan,项目名称:plot,代码行数:35,代码来源:main.go
示例14: Example_bubbles
func Example_bubbles() *plot.Plot {
rand.Seed(int64(0))
n := 10
bubbleData := randomTriples(n)
p, err := plot.New()
if err != nil {
panic(err)
}
p.Title.Text = "Bubbles"
p.X.Label.Text = "X"
p.Y.Label.Text = "Y"
bs, err := plotter.NewBubbles(bubbleData, vg.Points(1), vg.Points(20))
if err != nil {
panic(err)
}
bs.Color = color.RGBA{R: 196, B: 128, A: 255}
p.Add(bs)
return p
}
开发者ID:sksullivan,项目名称:plot,代码行数:22,代码来源:main.go
示例15: AddStackedAreaPlots
// AddStackedAreaPlots adds stacked area plot plotters to a plot.
// The variadic arguments must be either strings
// or plotter.Valuers. Each valuer adds a stacked area
// plot to the plot below the stacked area plots added
// before it. If a plotter.Valuer is immediately
// preceeded by a string then the string value is used to
// label the legend.
// Plots should be added in order of tallest to shortest,
// because they will be drawn in the order they are added
// (i.e. later plots will be painted over earlier plots).
//
// If an error occurs then none of the plotters are added
// to the plot, and the error is returned.
func AddStackedAreaPlots(plt *plot.Plot, xs plotter.Valuer, vs ...interface{}) error {
var ps []plot.Plotter
names := make(map[*plotter.Line]string)
name := ""
var i int
for _, v := range vs {
switch t := v.(type) {
case string:
name = t
case plotter.Valuer:
if xs.Len() != t.Len() {
return errors.New("X/Y length mismatch")
}
// Make a line plotter and set its style.
l, err := plotter.NewLine(combineXYs{xs: xs, ys: t})
if err != nil {
return err
}
l.LineStyle.Width = vg.Points(0)
color := Color(i)
i++
l.ShadeColor = &color
ps = append(ps, l)
if name != "" {
names[l] = name
name = ""
}
default:
panic(fmt.Sprintf("AddStackedAreaPlots handles strings and plotter.Valuers, got %T", t))
}
}
plt.Add(ps...)
for p, n := range names {
plt.Legend.Add(n, p)
}
return nil
}
开发者ID:sksullivan,项目名称:plot,代码行数:59,代码来源:add.go
示例16: Example_barChart
// An example of making a bar chart.
func Example_barChart() *plot.Plot {
groupA := plotter.Values{20, 35, 30, 35, 27}
groupB := plotter.Values{25, 32, 34, 20, 25}
groupC := plotter.Values{12, 28, 15, 21, 8}
groupD := plotter.Values{30, 42, 6, 9, 12}
p, err := plot.New()
if err != nil {
panic(err)
}
p.Title.Text = "Bar chart"
p.Y.Label.Text = "Heights"
w := vg.Points(8)
barsA := must(plotter.NewBarChart(groupA, w)).(*plotter.BarChart)
barsA.Color = color.RGBA{R: 255, A: 255}
barsA.Offset = -w / 2
barsB := must(plotter.NewBarChart(groupB, w)).(*plotter.BarChart)
barsB.Color = color.RGBA{R: 196, G: 196, A: 255}
barsB.Offset = w / 2
barsC := must(plotter.NewBarChart(groupC, w)).(*plotter.BarChart)
barsC.Color = color.RGBA{B: 255, A: 255}
barsC.XMin = 6
barsC.Offset = -w / 2
barsD := must(plotter.NewBarChart(groupD, w)).(*plotter.BarChart)
barsD.Color = color.RGBA{B: 255, R: 255, A: 255}
barsD.XMin = 6
barsD.Offset = w / 2
p.Add(barsA, barsB, barsC, barsD)
p.Legend.Add("A", barsA)
p.Legend.Add("B", barsB)
p.Legend.Add("C", barsC)
p.Legend.Add("D", barsD)
p.Legend.Top = true
p.NominalX("Zero", "One", "Two", "Three", "Four", "",
"Six", "Seven", "Eight", "Nine", "Ten")
return p
}
开发者ID:sksullivan,项目名称:plot,代码行数:45,代码来源:main.go
示例17: makeAxis
// makeAxis returns a default Axis.
//
// The default range is (∞, ∞), and thus any finite
// value is less than Min and greater than Max.
func makeAxis() (Axis, error) {
labelFont, err := vg.MakeFont(DefaultFont, vg.Points(12))
if err != nil {
return Axis{}, err
}
tickFont, err := vg.MakeFont(DefaultFont, vg.Points(10))
if err != nil {
return Axis{}, err
}
a := Axis{
Min: math.Inf(1),
Max: math.Inf(-1),
LineStyle: draw.LineStyle{
Color: color.Black,
Width: vg.Points(0.5),
},
Padding: vg.Points(5),
Scale: LinearScale{},
}
a.Label.TextStyle = draw.TextStyle{
Color: color.Black,
Font: labelFont,
}
a.Tick.Label = draw.TextStyle{
Color: color.Black,
Font: tickFont,
}
a.Tick.LineStyle = draw.LineStyle{
Color: color.Black,
Width: vg.Points(0.5),
}
a.Tick.Length = vg.Points(8)
a.Tick.Marker = DefaultTicks{}
return a, nil
}
开发者ID:sksullivan,项目名称:plot,代码行数:42,代码来源:axis.go
示例18: NewGlyphBoxes
func NewGlyphBoxes() *GlyphBoxes {
g := new(GlyphBoxes)
g.Color = color.RGBA{R: 255, A: 255}
g.Width = vg.Points(0.25)
return g
}
开发者ID:sksullivan,项目名称:plot,代码行数:6,代码来源:glyphbox.go
示例19:
// Copyright ©2015 The gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package plotter
import (
"math"
"github.com/sksullivan/plot"
"github.com/sksullivan/plot/vg"
"github.com/sksullivan/plot/vg/draw"
)
// DefaultCapWidth is the default width of error bar caps.
var DefaultCapWidth = vg.Points(5)
// YErrorBars implements the plot.Plotter, plot.DataRanger,
// and plot.GlyphBoxer interfaces, drawing vertical error
// bars, denoting error in Y values.
type YErrorBars struct {
XYs
// YErrors is a copy of the Y errors for each point.
YErrors
// LineStyle is the style used to draw the error bars.
draw.LineStyle
// CapWidth is the width of the caps drawn at the top
// of each error bar.
开发者ID:sksullivan,项目名称:plot,代码行数:31,代码来源:errbars.go
示例20:
package plotter
import (
"image/color"
"github.com/sksullivan/plot"
"github.com/sksullivan/plot/vg"
"github.com/sksullivan/plot/vg/draw"
)
var (
// DefaultQuartMedianStyle is a fat dot.
DefaultQuartMedianStyle = draw.GlyphStyle{
Color: color.Black,
Radius: vg.Points(1.5),
Shape: draw.CircleGlyph{},
}
// DefaultQuartWhiskerStyle is a hairline.
DefaultQuartWhiskerStyle = draw.LineStyle{
Color: color.Black,
Width: vg.Points(0.5),
Dashes: []vg.Length{},
DashOffs: 0,
}
)
// QuartPlot implements the Plotter interface, drawing
// a plot to represent the distribution of values.
//
开发者ID:sksullivan,项目名称:plot,代码行数:30,代码来源:quartile.go
注:本文中的github.com/sksullivan/plot/vg.Points函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论