-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
executable file
·697 lines (602 loc) · 18 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
package main
import (
"bufio"
"log"
"os"
"strconv"
"strings"
"github.com/spf13/cobra"
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/plotutil"
"gonum.org/v1/plot/vg"
)
/*
Author Gaurav Sablok
Universitat Potsdam
Date 2024-11-1
golang plotter for the whole genome annotations. Given a gff file, plots the strand
specific annotations for mRNA, cds, exons and others.
*/
func main() {
if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
}
os.Exit(1)
}
var annotationfile string
var rootCmd = &cobra.Command{
Use: "golanannotate",
Long: "annotate and visualize your genome",
Run: annotateFunc,
}
func init() {
rootCmd.Flags().
StringVarP(&annotationfile, "annotationfile", "A", "path to the annotation file", "genome annotation")
}
func annotateFunc(cmd *cobra.Command, args []string) {
type mRNADetails struct {
mRNAParent string
mRNAStrand string
mRNAStart int
mRNAEnd int
}
type exonDetails struct {
exonParent string
exonStrand string
exonStart int
exonEnd int
}
type proteinDetails struct {
proteinParent string
proteinStrand string
proteinStart int
proteinEnd int
}
type cdsDetails struct {
cdsParent string
cdsStrand string
cdsStart int
cdsEnd int
}
type fiveDetails struct {
fiveParent string
fiveStrand string
fiveStart int
fiveEnd int
}
type threeDetails struct {
threeParent string
threeStrand string
threeStart int
threeEnd int
}
mRNADet := []mRNADetails{}
exonDet := []exonDetails{}
cdsDet := []cdsDetails{}
proteinDet := []proteinDetails{}
threeDet := []threeDetails{}
fiveDet := []fiveDetails{}
annotateOpen, err := os.Open(annotationfile)
if err != nil {
log.Fatal(err)
}
annotateRead := bufio.NewScanner(annotateOpen)
for annotateRead.Scan() {
line := annotateRead.Text()
if strings.Split(line, "\t")[2] == "mRNA" {
start, _ := strconv.Atoi(strings.Split(string(line), "\t")[3])
end, _ := strconv.Atoi(strings.Split(string(line), "\t")[4])
mRNADet = append(mRNADet, mRNADetails{
mRNAParent: strings.Split(string(line), "\t")[2],
mRNAStrand: strings.Split(string(line), "\t")[6],
mRNAStart: start,
mRNAEnd: end,
})
}
if strings.Split(line, "\t")[2] == "exon" {
start, _ := strconv.Atoi(strings.Split(string(line), "\t")[3])
end, _ := strconv.Atoi(strings.Split(string(line), "\t")[4])
exonDet = append(exonDet, exonDetails{
exonParent: strings.Split(string(line), "\t")[2],
exonStrand: strings.Split(string(line), "\t")[6],
exonStart: start,
exonEnd: end,
})
}
if strings.Split(line, "\t")[2] == "CDS" {
start, _ := strconv.Atoi(strings.Split(string(line), "\t")[3])
end, _ := strconv.Atoi(strings.Split(string(line), "\t")[4])
cdsDet = append(cdsDet, cdsDetails{
cdsParent: strings.Split(string(line), "\t")[2],
cdsStrand: strings.Split(string(line), "\t")[6],
cdsStart: start,
cdsEnd: end,
})
}
if strings.Split(line, "\t")[2] == "protein" {
start, _ := strconv.Atoi(strings.Split(string(line), "\t")[3])
end, _ := strconv.Atoi(strings.Split(string(line), "\t")[4])
proteinDet = append(proteinDet, proteinDetails{
proteinParent: strings.Split(string(line), "\t")[2],
proteinStrand: strings.Split(string(line), "\t")[6],
proteinStart: start,
proteinEnd: end,
})
}
if strings.Split(line, "\t")[2] == "five_prime_UTR" {
start, _ := strconv.Atoi(strings.Split(string(line), "\t")[3])
end, _ := strconv.Atoi(strings.Split(string(line), "\t")[4])
fiveDet = append(fiveDet, fiveDetails{
fiveParent: strings.Split(string(line), "\t")[2],
fiveStrand: strings.Split(string(line), "\t")[6],
fiveStart: start,
fiveEnd: end,
})
}
if strings.Split(line, "\t")[2] == "three_prime_UTR" {
start, _ := strconv.Atoi(strings.Split(string(line), "\t")[3])
end, _ := strconv.Atoi(strings.Split(string(line), "\t")[4])
threeDet = append(threeDet, threeDetails{
threeParent: strings.Split(string(line), "\t")[2],
threeStrand: strings.Split(string(line), "\t")[6],
threeStart: start,
threeEnd: end,
})
}
}
exonLengthPlot := []int{}
mRNALengthPlot := []int{}
cdsLengthPlot := []int{}
proteinLengthPlot := []int{}
threeLengthPlot := []int{}
fiveLengthPlot := []int{}
for i := range exonDet {
exonLengthPlot = append(exonLengthPlot, exonDet[i].exonEnd-exonDet[i].exonStart)
}
for i := range mRNADet {
mRNALengthPlot = append(mRNALengthPlot, mRNADet[i].mRNAEnd-mRNADet[i].mRNAStart)
}
for i := range cdsDet {
cdsLengthPlot = append(cdsLengthPlot, cdsDet[i].cdsEnd-cdsDet[i].cdsStart)
}
for i := range proteinDet {
proteinLengthPlot = append(
proteinLengthPlot,
proteinDet[i].proteinEnd-proteinDet[i].proteinStart,
)
}
for i := range threeDet {
threeLengthPlot = append(threeLengthPlot, threeDet[i].threeEnd-threeDet[i].threeStart)
}
for i := range fiveDet {
fiveLengthPlot = append(fiveLengthPlot, fiveDet[i].fiveEnd-fiveDet[i].fiveStart)
}
exonPlusLengthPlot := []int{}
mRNAPlusLengthPlot := []int{}
cdsPlusLengthPlot := []int{}
proteinPlusLengthPlot := []int{}
threePlusLengthPlot := []int{}
fivePlusLengthPlot := []int{}
exonMinusLengthPlot := []int{}
mRNAMinusLengthPlot := []int{}
cdsMinusLengthPlot := []int{}
proteinMinusLengthPlot := []int{}
threeMinusLengthPlot := []int{}
fiveMinusLengthPlot := []int{}
for i := range exonDet {
if exonDet[i].exonStrand == "+" {
exonPlusLengthPlot = append(exonPlusLengthPlot, exonDet[i].exonEnd-exonDet[i].exonStart)
}
if exonDet[i].exonStrand == "-" {
exonMinusLengthPlot = append(
exonMinusLengthPlot,
exonDet[i].exonEnd-exonDet[i].exonStart,
)
}
}
for i := range mRNADet {
if mRNADet[i].mRNAStrand == "+" {
mRNAPlusLengthPlot = append(mRNAPlusLengthPlot, mRNADet[i].mRNAEnd-mRNADet[i].mRNAStart)
}
if mRNADet[i].mRNAStrand == "-" {
mRNAMinusLengthPlot = append(
mRNAMinusLengthPlot,
mRNADet[i].mRNAEnd-mRNADet[i].mRNAStart,
)
}
}
for i := range cdsDet {
if cdsDet[i].cdsStrand == "+" {
cdsPlusLengthPlot = append(cdsPlusLengthPlot, cdsDet[i].cdsEnd-cdsDet[i].cdsStart)
}
if cdsDet[i].cdsStrand == "-" {
cdsMinusLengthPlot = append(
cdsMinusLengthPlot,
cdsDet[i].cdsEnd-cdsDet[i].cdsStart,
)
}
}
for i := range fiveDet {
if fiveDet[i].fiveStrand == "+" {
fivePlusLengthPlot = append(fivePlusLengthPlot, fiveDet[i].fiveEnd-fiveDet[i].fiveStart)
}
if fiveDet[i].fiveStrand == "-" {
fiveMinusLengthPlot = append(
fiveMinusLengthPlot,
fiveDet[i].fiveEnd-fiveDet[i].fiveStart,
)
}
}
for i := range threeDet {
if threeDet[i].threeStrand == "+" {
threePlusLengthPlot = append(
threePlusLengthPlot,
threeDet[i].threeEnd-threeDet[i].threeStart,
)
}
if threeDet[i].threeStrand == "-" {
threeMinusLengthPlot = append(
threeMinusLengthPlot,
threeDet[i].threeEnd-threeDet[i].threeStart,
)
}
}
for i := range proteinDet {
if proteinDet[i].proteinStrand == "+" {
proteinPlusLengthPlot = append(
proteinPlusLengthPlot,
proteinDet[i].proteinEnd-proteinDet[i].proteinStart,
)
}
if proteinDet[i].proteinStrand == "-" {
proteinMinusLengthPlot = append(
proteinMinusLengthPlot,
proteinDet[i].proteinEnd-proteinDet[i].proteinStart,
)
}
}
var mRNAPlotter plotter.Values
var mRNAPlusPlotter plotter.Values
var mRNAMinusPlotter plotter.Values
for i := range mRNALengthPlot {
mRNAPlotter = append(mRNAPlotter, float64(mRNALengthPlot[i]))
}
mRNA := plot.New()
mRNA.Title.Text = "Bar chart"
mRNA.Y.Label.Text = "mRNA"
w := vg.Points(14)
barsmRNA, err := plotter.NewBarChart(mRNAPlotter, w)
if err != nil {
panic(err)
}
barsmRNA.LineStyle.Width = vg.Length(0)
barsmRNA.Color = plotutil.Color(0)
barsmRNA.Offset = -w
mRNA.Add(barsmRNA)
mRNA.Legend.Add("mRNA", barsmRNA)
if err := mRNA.Save(20*vg.Inch, 10*vg.Inch, "barmRNA.png"); err != nil {
panic(err)
}
for i := range mRNAPlusLengthPlot {
mRNAPlusPlotter = append(mRNAPlusPlotter, float64(mRNAPlusLengthPlot[i]))
}
mRNAPlus := plot.New()
mRNAPlus.Title.Text = "Bar chart"
mRNAPlus.Y.Label.Text = "mRNAPlus"
barsmRNAPlus, err := plotter.NewBarChart(mRNAPlusPlotter, w)
if err != nil {
panic(err)
}
barsmRNAPlus.LineStyle.Width = vg.Length(0)
barsmRNAPlus.Color = plotutil.Color(0)
barsmRNAPlus.Offset = -w
mRNAPlus.Add(barsmRNAPlus)
mRNAPlus.Legend.Add("mRNAPlus", barsmRNAPlus)
if err := mRNAPlus.Save(20*vg.Inch, 10*vg.Inch, "barmRNAPlus.png"); err != nil {
panic(err)
}
for i := range mRNAMinusLengthPlot {
mRNAMinusPlotter = append(mRNAPlotter, float64(mRNAMinusLengthPlot[i]))
}
mRNAMinus := plot.New()
mRNAMinus.Title.Text = "Bar chart"
mRNAMinus.Y.Label.Text = "mRNA"
barsmRNAMinus, err := plotter.NewBarChart(mRNAMinusPlotter, w)
if err != nil {
panic(err)
}
barsmRNAMinus.LineStyle.Width = vg.Length(0)
barsmRNAMinus.Color = plotutil.Color(0)
barsmRNAMinus.Offset = -w
mRNAMinus.Add(barsmRNA)
mRNAMinus.Legend.Add("mRNAMinus", barsmRNAMinus)
if err := mRNA.Save(20*vg.Inch, 10*vg.Inch, "barmRNAMinus.png"); err != nil {
panic(err)
}
var cdsPlotter plotter.Values
var cdsPlusPlotter plotter.Values
var cdsMinusPlotter plotter.Values
for i := range cdsLengthPlot {
cdsPlotter = append(cdsPlotter, float64(cdsLengthPlot[i]))
}
cds := plot.New()
cds.Title.Text = "Bar chart"
cds.Y.Label.Text = "cds"
barscds, err := plotter.NewBarChart(cdsPlotter, w)
if err != nil {
panic(err)
}
barscds.LineStyle.Width = vg.Length(0)
barscds.Color = plotutil.Color(0)
barscds.Offset = -w
cds.Add(barscds)
cds.Legend.Add("cds", barscds)
if err := cds.Save(20*vg.Inch, 10*vg.Inch, "barcds.png"); err != nil {
panic(err)
}
for i := range cdsPlusLengthPlot {
cdsPlusPlotter = append(cdsPlusPlotter, float64(cdsPlusLengthPlot[i]))
}
cdsPlus := plot.New()
cdsPlus.Title.Text = "Bar chart"
cdsPlus.Y.Label.Text = "cdsPlus"
barscdsPlus, err := plotter.NewBarChart(cdsPlusPlotter, w)
if err != nil {
panic(err)
}
barscdsPlus.LineStyle.Width = vg.Length(0)
barscdsPlus.Color = plotutil.Color(0)
barscdsPlus.Offset = -w
cdsPlus.Add(barscdsPlus)
cdsPlus.Legend.Add("cdsPlus", barscdsPlus)
if err := cdsPlus.Save(20*vg.Inch, 10*vg.Inch, "barcdsPlus.png"); err != nil {
panic(err)
}
for i := range cdsMinusLengthPlot {
cdsMinusPlotter = append(cdsPlotter, float64(cdsMinusLengthPlot[i]))
}
cdsMinus := plot.New()
cdsMinus.Title.Text = "Bar chart"
cdsMinus.Y.Label.Text = "cds"
barscdsMinus, err := plotter.NewBarChart(cdsMinusPlotter, w)
if err != nil {
panic(err)
}
barscdsMinus.LineStyle.Width = vg.Length(0)
barscdsMinus.Color = plotutil.Color(0)
barscdsMinus.Offset = -w
cdsMinus.Add(barscds)
cdsMinus.Legend.Add("cdsMinus", barscdsMinus)
if err := cds.Save(20*vg.Inch, 10*vg.Inch, "barcdsMinus.png"); err != nil {
panic(err)
}
var exonPlotter plotter.Values
var exonPlusPlotter plotter.Values
var exonMinusPlotter plotter.Values
for i := range exonLengthPlot {
exonPlotter = append(exonPlotter, float64(exonLengthPlot[i]))
}
exon := plot.New()
exon.Title.Text = "Bar chart"
exon.Y.Label.Text = "exon"
barsexon, err := plotter.NewBarChart(exonPlotter, w)
if err != nil {
panic(err)
}
barsexon.LineStyle.Width = vg.Length(0)
barsexon.Color = plotutil.Color(0)
barsexon.Offset = -w
exon.Add(barsexon)
exon.Legend.Add("exon", barsexon)
if err := exon.Save(20*vg.Inch, 10*vg.Inch, "barexon.png"); err != nil {
panic(err)
}
for i := range exonPlusLengthPlot {
exonPlusPlotter = append(exonPlusPlotter, float64(exonPlusLengthPlot[i]))
}
exonPlus := plot.New()
exonPlus.Title.Text = "Bar chart"
exonPlus.Y.Label.Text = "exonPlus"
barsexonPlus, err := plotter.NewBarChart(exonPlusPlotter, w)
if err != nil {
panic(err)
}
barsexonPlus.LineStyle.Width = vg.Length(0)
barsexonPlus.Color = plotutil.Color(0)
barsexonPlus.Offset = -w
exonPlus.Add(barsexonPlus)
exonPlus.Legend.Add("exonPlus", barsexonPlus)
if err := exonPlus.Save(20*vg.Inch, 10*vg.Inch, "barexonPlus.png"); err != nil {
panic(err)
}
for i := range exonMinusLengthPlot {
exonMinusPlotter = append(exonPlotter, float64(exonMinusLengthPlot[i]))
}
exonMinus := plot.New()
exonMinus.Title.Text = "Bar chart"
exonMinus.Y.Label.Text = "exon"
barsexonMinus, err := plotter.NewBarChart(exonMinusPlotter, w)
if err != nil {
panic(err)
}
barsexonMinus.LineStyle.Width = vg.Length(0)
barsexonMinus.Color = plotutil.Color(0)
barsexonMinus.Offset = -w
exonMinus.Add(barsexon)
exonMinus.Legend.Add("exonMinus", barsexonMinus)
if err := exon.Save(20*vg.Inch, 10*vg.Inch, "barexonMinus.png"); err != nil {
panic(err)
}
var proteinPlotter plotter.Values
var proteinPlusPlotter plotter.Values
var proteinMinusPlotter plotter.Values
for i := range proteinLengthPlot {
proteinPlotter = append(proteinPlotter, float64(proteinLengthPlot[i]))
}
protein := plot.New()
protein.Title.Text = "Bar chart"
protein.Y.Label.Text = "protein"
barsprotein, err := plotter.NewBarChart(proteinPlotter, w)
if err != nil {
panic(err)
}
barsprotein.LineStyle.Width = vg.Length(0)
barsprotein.Color = plotutil.Color(0)
barsprotein.Offset = -w
protein.Add(barsprotein)
protein.Legend.Add("protein", barsprotein)
if err := protein.Save(20*vg.Inch, 10*vg.Inch, "barprotein.png"); err != nil {
panic(err)
}
for i := range proteinPlusLengthPlot {
proteinPlusPlotter = append(proteinPlusPlotter, float64(proteinPlusLengthPlot[i]))
}
proteinPlus := plot.New()
proteinPlus.Title.Text = "Bar chart"
proteinPlus.Y.Label.Text = "proteinPlus"
barsproteinPlus, err := plotter.NewBarChart(proteinPlusPlotter, w)
if err != nil {
panic(err)
}
barsproteinPlus.LineStyle.Width = vg.Length(0)
barsproteinPlus.Color = plotutil.Color(0)
barsproteinPlus.Offset = -w
proteinPlus.Add(barsproteinPlus)
proteinPlus.Legend.Add("proteinPlus", barsproteinPlus)
if err := proteinPlus.Save(20*vg.Inch, 10*vg.Inch, "barproteinPlus.png"); err != nil {
panic(err)
}
for i := range proteinMinusLengthPlot {
proteinMinusPlotter = append(proteinPlotter, float64(proteinMinusLengthPlot[i]))
}
proteinMinus := plot.New()
proteinMinus.Title.Text = "Bar chart"
proteinMinus.Y.Label.Text = "protein"
barsproteinMinus, err := plotter.NewBarChart(proteinMinusPlotter, w)
if err != nil {
panic(err)
}
barsproteinMinus.LineStyle.Width = vg.Length(0)
barsproteinMinus.Color = plotutil.Color(0)
barsproteinMinus.Offset = -w
proteinMinus.Add(barsprotein)
proteinMinus.Legend.Add("proteinMinus", barsproteinMinus)
if err := protein.Save(20*vg.Inch, 10*vg.Inch, "barproteinMinus.png"); err != nil {
panic(err)
}
var threePlotter plotter.Values
var threePlusPlotter plotter.Values
var threeMinusPlotter plotter.Values
for i := range threeLengthPlot {
threePlotter = append(threePlotter, float64(threeLengthPlot[i]))
}
three := plot.New()
three.Title.Text = "Bar chart"
three.Y.Label.Text = "three"
barsthree, err := plotter.NewBarChart(threePlotter, w)
if err != nil {
panic(err)
}
barsthree.LineStyle.Width = vg.Length(0)
barsthree.Color = plotutil.Color(0)
barsthree.Offset = -w
three.Add(barsthree)
three.Legend.Add("three", barsthree)
if err := three.Save(20*vg.Inch, 10*vg.Inch, "barthree.png"); err != nil {
panic(err)
}
for i := range threePlusLengthPlot {
threePlusPlotter = append(threePlusPlotter, float64(threePlusLengthPlot[i]))
}
threePlus := plot.New()
threePlus.Title.Text = "Bar chart"
threePlus.Y.Label.Text = "threePlus"
barsthreePlus, err := plotter.NewBarChart(threePlusPlotter, w)
if err != nil {
panic(err)
}
barsthreePlus.LineStyle.Width = vg.Length(0)
barsthreePlus.Color = plotutil.Color(0)
barsthreePlus.Offset = -w
threePlus.Add(barsthreePlus)
threePlus.Legend.Add("threePlus", barsthreePlus)
if err := threePlus.Save(20*vg.Inch, 10*vg.Inch, "barthreePlus.png"); err != nil {
panic(err)
}
for i := range threeMinusLengthPlot {
threeMinusPlotter = append(threePlotter, float64(threeMinusLengthPlot[i]))
}
threeMinus := plot.New()
threeMinus.Title.Text = "Bar chart"
threeMinus.Y.Label.Text = "three"
barsthreeMinus, err := plotter.NewBarChart(threeMinusPlotter, w)
if err != nil {
panic(err)
}
barsthreeMinus.LineStyle.Width = vg.Length(0)
barsthreeMinus.Color = plotutil.Color(0)
barsthreeMinus.Offset = -w
threeMinus.Add(barsthree)
threeMinus.Legend.Add("threeMinus", barsthreeMinus)
if err := three.Save(20*vg.Inch, 10*vg.Inch, "barthreeMinus.png"); err != nil {
panic(err)
}
var fivePlotter plotter.Values
var fivePlusPlotter plotter.Values
var fiveMinusPlotter plotter.Values
for i := range fiveLengthPlot {
fivePlotter = append(fivePlotter, float64(fiveLengthPlot[i]))
}
five := plot.New()
five.Title.Text = "Bar chart"
five.Y.Label.Text = "five"
barsfive, err := plotter.NewBarChart(fivePlotter, w)
if err != nil {
panic(err)
}
barsfive.LineStyle.Width = vg.Length(0)
barsfive.Color = plotutil.Color(0)
barsfive.Offset = -w
five.Add(barsfive)
five.Legend.Add("five", barsfive)
if err := five.Save(20*vg.Inch, 10*vg.Inch, "barfive.png"); err != nil {
panic(err)
}
for i := range fivePlusLengthPlot {
fivePlusPlotter = append(fivePlusPlotter, float64(fivePlusLengthPlot[i]))
}
fivePlus := plot.New()
fivePlus.Title.Text = "Bar chart"
fivePlus.Y.Label.Text = "fivePlus"
barsfivePlus, err := plotter.NewBarChart(fivePlusPlotter, w)
if err != nil {
panic(err)
}
barsfivePlus.LineStyle.Width = vg.Length(0)
barsfivePlus.Color = plotutil.Color(0)
barsfivePlus.Offset = -w
fivePlus.Add(barsfivePlus)
fivePlus.Legend.Add("fivePlus", barsfivePlus)
if err := fivePlus.Save(20*vg.Inch, 10*vg.Inch, "barfivePlus.png"); err != nil {
panic(err)
}
for i := range fiveMinusLengthPlot {
fiveMinusPlotter = append(fivePlotter, float64(fiveMinusLengthPlot[i]))
}
fiveMinus := plot.New()
fiveMinus.Title.Text = "Bar chart"
fiveMinus.Y.Label.Text = "five"
barsfiveMinus, err := plotter.NewBarChart(fiveMinusPlotter, w)
if err != nil {
panic(err)
}
barsfiveMinus.LineStyle.Width = vg.Length(0)
barsfiveMinus.Color = plotutil.Color(0)
barsfiveMinus.Offset = -w
fiveMinus.Add(barsfive)
fiveMinus.Legend.Add("fiveMinus", barsfiveMinus)
if err := five.Save(20*vg.Inch, 10*vg.Inch, "barfiveMinus.png"); err != nil {
panic(err)
}
}