本文整理汇总了Golang中github.com/skiesel/plot.Plot.NominalX方法的典型用法代码示例。如果您正苦于以下问题:Golang Plot.NominalX方法的具体用法?Golang Plot.NominalX怎么用?Golang Plot.NominalX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skiesel/plot.Plot
的用法示例。
在下文中一共展示了Plot.NominalX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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.
//
// If an error occurs then none of the plotters are added
// to the plot, and the error is returned.
func AddBoxPlots(plt *plot.Plot, width vg.Length, vs ...interface{}) error {
var ps []plot.Plotter
var names []string
name := ""
for _, v := range vs {
switch t := v.(type) {
case string:
name = t
case plotter.Valuer:
b, err := plotter.NewBoxPlot(width, float64(len(names)), t)
if err != nil {
return err
}
ps = append(ps, b)
names = append(names, name)
name = ""
default:
panic(fmt.Sprintf("AddBoxPlots handles strings and plotter.Valuers, got %T", t))
}
}
plt.Add(ps...)
plt.NominalX(names...)
return nil
}