genPlotXY generates an XY (lines, points) plot, setting Plot variable
()
| 19 | |
| 20 | // genPlotXY generates an XY (lines, points) plot, setting Plot variable |
| 21 | func (pl *PlotEditor) genPlotXY() { |
| 22 | plt := plot.New() |
| 23 | |
| 24 | // process xaxis first |
| 25 | xi, xview, err := pl.plotXAxis(plt, pl.table) |
| 26 | if err != nil { |
| 27 | return |
| 28 | } |
| 29 | xp := pl.Columns[xi] |
| 30 | |
| 31 | var lsplit *table.Splits |
| 32 | nleg := 1 |
| 33 | if pl.Options.Legend != "" { |
| 34 | _, err = pl.table.Table.ColumnIndexTry(pl.Options.Legend) |
| 35 | if err != nil { |
| 36 | slog.Error("plot.Legend", "err", err.Error()) |
| 37 | } else { |
| 38 | errors.Log(xview.SortStableColumnNames([]string{pl.Options.Legend, xp.Column}, table.Ascending)) |
| 39 | lsplit = split.GroupBy(xview, pl.Options.Legend) |
| 40 | nleg = max(lsplit.Len(), 1) |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | var firstXY *tableXY |
| 45 | var strCols []*ColumnOptions |
| 46 | nys := 0 |
| 47 | for _, cp := range pl.Columns { |
| 48 | if !cp.On { |
| 49 | continue |
| 50 | } |
| 51 | if cp.IsString { |
| 52 | strCols = append(strCols, cp) |
| 53 | continue |
| 54 | } |
| 55 | if cp.TensorIndex < 0 { |
| 56 | yc := pl.table.Table.ColumnByName(cp.Column) |
| 57 | _, sz := yc.RowCellSize() |
| 58 | nys += sz |
| 59 | } else { |
| 60 | nys++ |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | if nys == 0 { |
| 65 | return |
| 66 | } |
| 67 | |
| 68 | firstXY = nil |
| 69 | yidx := 0 |
| 70 | for _, cp := range pl.Columns { |
| 71 | if !cp.On || cp == xp { |
| 72 | continue |
| 73 | } |
| 74 | if cp.IsString { |
| 75 | continue |
| 76 | } |
| 77 | for li := 0; li < nleg; li++ { |
| 78 | lview := xview |
no test coverage detected