bar plot is on integer positions, with different Y values and / or legend values interleaved genPlotBar generates a Bar plot, setting GPlot variable
()
| 22 | |
| 23 | // genPlotBar generates a Bar plot, setting GPlot variable |
| 24 | func (pl *PlotEditor) genPlotBar() { |
| 25 | plt := plot.New() // note: not clear how to re-use, due to newtablexynames |
| 26 | if pl.Options.BarWidth > 1 { |
| 27 | pl.Options.BarWidth = .8 |
| 28 | } |
| 29 | |
| 30 | // process xaxis first |
| 31 | xi, xview, err := pl.plotXAxis(plt, pl.table) |
| 32 | if err != nil { |
| 33 | return |
| 34 | } |
| 35 | xp := pl.Columns[xi] |
| 36 | |
| 37 | var lsplit *table.Splits |
| 38 | nleg := 1 |
| 39 | if pl.Options.Legend != "" { |
| 40 | _, err = pl.table.Table.ColumnIndexTry(pl.Options.Legend) |
| 41 | if err != nil { |
| 42 | log.Println("plot.Legend: " + err.Error()) |
| 43 | } else { |
| 44 | xview.SortColumnNames([]string{pl.Options.Legend, xp.Column}, table.Ascending) // make it fit! |
| 45 | lsplit = split.GroupBy(xview, pl.Options.Legend) |
| 46 | nleg = max(lsplit.Len(), 1) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | var firstXY *tableXY |
| 51 | var strCols []*ColumnOptions |
| 52 | nys := 0 |
| 53 | for _, cp := range pl.Columns { |
| 54 | if !cp.On { |
| 55 | continue |
| 56 | } |
| 57 | if cp.IsString { |
| 58 | strCols = append(strCols, cp) |
| 59 | continue |
| 60 | } |
| 61 | if cp.TensorIndex < 0 { |
| 62 | yc := pl.table.Table.ColumnByName(cp.Column) |
| 63 | _, sz := yc.RowCellSize() |
| 64 | nys += sz |
| 65 | } else { |
| 66 | nys++ |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | if nys == 0 { |
| 71 | return |
| 72 | } |
| 73 | |
| 74 | stride := nys * nleg |
| 75 | if stride > 1 { |
| 76 | stride += 1 // extra gap |
| 77 | } |
| 78 | |
| 79 | yoff := 0 |
| 80 | yidx := 0 |
| 81 | maxx := 0 // max number of x values |
no test coverage detected