Report abuse

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
! Requires 4.0.13 

size 12 8
set font ss
include "barstyles.gle"
set lwidth 0.01

sub cf z x
  local y = 0.4 ! set to 0 to fade completely white, 1 no fade at all
  return (z*(1-y)+y)*(x/255-1)+1 ! The final +1 hard codes this to fade to white
end sub

sub local_palette z r g b
! r, g, b is the color of the gradient which will fade towards white
  return cvtrgb(cf(z,r),cf(z,g),cf(z,b))
end sub

sub purple_palette z
  return local_palette(z, 94, 19, 175)
end sub

sub yellow_palette z
  return local_palette(z, 255, 255, 0)
end sub

sub customcolormap x1 y1 x2 y2 val g palette$
  amove x1 y1
  colormap y 0 1 0 1 1 200 x2-x1 y2-y1 palette palette$
  
  ! draw data labels, this is much less code than using custom markers
  gsave
  set just bc hei 0.23
  if val < 0 then y2 = yg(0)
  amove (x1+x2)/2 y2+0.1
  write (format$(val, "fix 2") + "%")
  grestore
end sub

sub bar_purplecolormap x1 y1 x2 y2 b g
  customcolormap x1 y1 x2 y2 b g purple_palette
end sub

sub bar_yellowcolormap x1 y1 x2 y2 b g
  customcolormap x1 y1 x2 y2 b g yellow_palette
end sub

begin graph
  data "gle/colorbar.dat"
  x2axis off
  xaxis min 0.5 max 4.5 dticks 1
  xdsubticks off
  y2axis off
  yaxis min -5 max 90 dticks 10 format "fix 0 append '%'" grid ontop
  yticks color grey20
  ytitle "Performance"
  bar d1,d2 width 0.3,0.3 style purplecolormap,yellowcolormap
end graph

begin key
  position bc coldist 0.5 offset 0 -0.5 nobox base 0.25 hei 0.25 boxcolor clear
  text "Series 1" fill rgb255(94,19,175) separator
  text "Series 2" fill rgb255(255,255,0)
end key