pro mg_sparkdichotomous, filename, data, ysize=ysize, $
color=color, background=background
compile_opt strictarr
n_data = n_elements(data)
multiplier = 1L
my_xsize = 2 * n_data - 1L
my_ysize = n_elements(ysize) eq 0 ? 12 : ysize
my_color = n_elements(color) eq 0 ? bytarr(3) : color
my_background = n_elements(background) eq 0 ? bytarr(3) + 255B : background
band = bytarr(my_xsize, my_ysize)
for i = 0L, n_data - 1L do begin
case 1B of
data[i] lt 0 : begin
bar_min = 0
bar_max = my_ysize / 2 - 1L
end
data[i] gt 0 : begin
bar_min = my_ysize / 2
bar_max = my_ysize - 1L
end
else : begin
bar_min = my_ysize / 2
bar_max = my_ysize / 2
end
endcase
band[2*i, bar_min:bar_max] = 1B
endfor
red = [my_background[0], my_color[0]]
green = [my_background[1], my_color[1]]
blue = [my_background[2], my_color[2]]
alpha = [0B, 255B]
hasAlpha = n_elements(background) eq 0
image = bytarr(3 + hasAlpha, my_xsize, my_ysize)
image[0, *, *] = red[band]
image[1, *, *] = green[band]
image[2, *, *] = blue[band]
if (hasAlpha) then image[3, *, *] = alpha[band]
write_png, filename, image
end