当前位置: 首页>>代码示例>>Golang>>正文


Golang Plot.Add方法代码示例

本文整理汇总了Golang中github.com/vron/plotinum/plot.Plot.Add方法的典型用法代码示例。如果您正苦于以下问题:Golang Plot.Add方法的具体用法?Golang Plot.Add怎么用?Golang Plot.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/vron/plotinum/plot.Plot的用法示例。


在下文中一共展示了Plot.Add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: AddErrorBars

// AddErrorBars adds XErrorBars and YErrorBars
// to a plot.  The variadic arguments must be
// of type plotter.XYer, and must be either a
// plotter.XErrorer, plotter.YErrorer, or both.
// Each errorer is added to the plot the color from
// the Colors function corresponding to its position
// in the argument list.
func AddErrorBars(plt *plot.Plot, vs ...interface{}) {
	for i, v := range vs {
		added := false

		if xerr, ok := v.(interface {
			plotter.XYer
			plotter.XErrorer
		}); ok {
			e := plotter.NewXErrorBars(xerr)
			e.Color = Color(i)
			plt.Add(e)
			added = true
		}

		if yerr, ok := v.(interface {
			plotter.XYer
			plotter.YErrorer
		}); ok {
			e := plotter.NewYErrorBars(yerr)
			e.Color = Color(i)
			plt.Add(e)
			added = true
		}

		if added {
			continue
		}
		panic(fmt.Sprintf("AddErrorBars expects plotter.XErrorer or plotter.YErrorer, got %T", v))
	}
}
开发者ID:vron,项目名称:plotinum,代码行数:37,代码来源:add.go

示例2: AddLinePoints

// AddLinePoints adds Line and Scatter plotters to a
// plot.  The variadic arguments must be either strings
// or plotter.XYers.  Each plotter.XYer is added to
// the plot using the next color, dashes, and glyph
// shape via the Color, Dashes, and Shape functions.
// If a plotter.XYer is immediately preceeded by
// a string then a legend entry is added to the plot
// using the string as the name.
func AddLinePoints(plt *plot.Plot, vs ...interface{}) {
	name := ""
	var i int
	for _, v := range vs {
		switch t := v.(type) {
		case string:
			name = t

		case plotter.XYer:
			l, s := plotter.NewLinePoints(t)
			l.Color = Color(i)
			l.Dashes = Dashes(i)
			s.Color = Color(i)
			s.Shape = Shape(i)
			i++
			plt.Add(l, s)
			if name != "" {
				plt.Legend.Add(name, l, s)
				name = ""
			}

		default:
			panic(fmt.Sprintf("AddLinePoints handles strings and plotter.XYers, got %T", t))
		}
	}
}
开发者ID:vron,项目名称:plotinum,代码行数:34,代码来源:add.go

示例3: AddYErrorBars

// AddYErrorBars adds YErrorBars to a plot.
// The variadic arguments must be
// of type plotter.XYer, and plotter.YErrorer.
// Each errorer is added to the plot the color from
// the Colors function corresponding to its position
// in the argument list.
func AddYErrorBars(plt *plot.Plot, es ...interface {
	plotter.XYer
	plotter.YErrorer
}) {
	for i, e := range es {
		bars := plotter.NewYErrorBars(e)
		bars.Color = Color(i)
		plt.Add(bars)
	}
}
开发者ID:vron,项目名称:plotinum,代码行数:16,代码来源:add.go

示例4: AddBoxPlots

// AddBoxPlots adds box plot plotters to a plot and
// sets the X axis of the plot to be nominal.
// The variadic arguments must be either strings
// or plotter.Valuers.  Each valuer adds a box plot
// to the plot at the X location corresponding to
// the number of box plots added before it.  If a
// plotter.Valuer is immediately preceeded by a
// string then the string value is used to label the
// tick mark for the box plot's X location.
func AddBoxPlots(plt *plot.Plot, width vg.Length, vs ...interface{}) {
	var names []string
	name := ""
	for _, v := range vs {
		switch t := v.(type) {
		case string:
			name = t

		case plotter.Valuer:
			plt.Add(plotter.NewBoxPlot(width, float64(len(names)), t))
			names = append(names, name)
			name = ""

		default:
			panic(fmt.Sprintf("AddScatters handles strings and plotter.XYers, got %T", t))
		}
	}
	plt.NominalX(names...)
}
开发者ID:vron,项目名称:plotinum,代码行数:28,代码来源:add.go


注:本文中的github.com/vron/plotinum/plot.Plot.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。