Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the bar chart below:

enter image description here

My code:

BarChart[{Labeled[{a760, c760, b760, d760}, "760" ], 
  Labeled[{a780, c780, b780, d780}, "780" ]}, 
 ChartStyle -> {Blue, Red, Green, Black}, 
 ChartLegends -> 
  Placed[{"65.5 ps", "274 ps", "16.8 ps", "2040 ps" }, {Right}], 
 BarSpacing -> {0, 1}]

The third entry of 780 is missing, so I used Missing[]. I want to attach the forth entry

of 780 to the second entry of 780. The point is that the color of the forth entry must

remain black because each color indicates a quality such as lifetimes.

share|improve this question
When you say "attach" do you mean "stack"? That is, to put the black bar on top of the red bar? Or below? Or what does attach mean in this case? – C. E. Mar 26 '14 at 13:45
I mean put the dark one alongside of the red one. I want them side to side. – MOON Mar 26 '14 at 15:31
Please include the data, if possible so we can reproduce your graph and inspect it. – DavidC Mar 26 '14 at 16:52
up vote 4 down vote accepted

I can't think of any clever way to remove the gap, so here is a way to get the chart using Style to specify individual colours for the bars:

data1 = {10, 5, 20, 2};
data2 = {12, 8, Missing[], 3};

colors = {Blue, Red, Green, Black};

applycolors = Style @@@ DeleteCases[Thread @ {#, colors}, {Missing[], _}] &;

   Labeled[applycolors @ data1, "760"],
   Labeled[applycolors @ data2, "780"]},
  BarSpacing -> {0, 1}] ~Legended~
 SwatchLegend[colors, {"65.5 ps", "274 ps", "16.8 ps", "2040 ps"}]

enter image description here

share|improve this answer
Thank you. Your answer is exactly what I needed. – MOON Mar 27 '14 at 0:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.