use each_with_index.
Added custom error bar option.