2
$\begingroup$

EdgeForm is not producing correct colors for the borders of my bars. My code:

data1 = {{1, 20, 300}, {.1, .2, .2}};
errorbarwidth = -0.1;
thickness = 0.005;
barchart[x_, thick_] := 
Module[{}, 
  errorBar[type_: "Rectangle"][{{x0_, x1_}, {y0_, y1_}}, value_, 
  meta_] := Block[{error}, error = Flatten[meta];
  error = If[error === {}, 0, Last[error]];
  {ChartElementData[type][{{x0, x1}, {y0, y1}}, value, 
  meta], {Black, 
  Line[{{{(x0 + x1)/2, y1 - error}, {(x0 + x1)/2, 
      y1 + error}}, {{1/4 (3 x0 + x1) - x, 
      y1 + error}, {1/4 (x0 + 3 x1) + x, 
      y1 + error}}, {{1/4 (3 x0 + x1) - x, 
      y1 - error}, {1/4 (x0 + 3 x1) + x, y1 - error}}}]}}];
  chartData = MapThread[#1 -> #2 &, data1];
  BarChart[chartData, ChartElementFunction -> errorBar["Rectangle"], 
    AspectRatio -> 0.6, ScalingFunctions -> "Log", 
    AxesStyle -> {Thickness[thick], Thickness[thick]}, 
    ChartStyle -> {Directive[White, EdgeForm[{Thickness[thick], Black}]], 
    Directive[Gray, EdgeForm[{Thickness[thick], Black}]], 
    Directive[Black,EdgeForm[{Thickness[thick], Black}]]}, 
    ChartLabels -> {Text[Style[label1, 14]], Text[Style[label2, 14]], 
    Text[Style[label3, 14]]}, ImageSize -> 700]]

plot1 = barchart[errorbarwidth, thickness]  

My EdgeForm commands are all specifying the edges to be black, but they come out gray. I am using Mathematica 9 BTW.

$\endgroup$
7
$\begingroup$

I figured it out -- turns out the default opacity is not 1 for the borders, making them appear gray. I modified EdgeForm:

EdgeForm[{Thickness[thick], Black, Opacity[1]}]

and it worked just fine.

$\endgroup$
  • 2
    $\begingroup$ Thanks for sharing your solution. $\endgroup$ – Mr.Wizard Sep 19 '15 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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