Skip to main content
deleted 67 characters in body
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

For Version 7

At least inIn version 7 the underlying Graphics expression that is produced by BarChart is highly conducive to a post-processing approach.

  • Each bar and label is contained in an expression that also includes style information.

  • The label however has an additional Style wrapper to effectively reset the color.

  • To style the bars and labels similarly we need only to remove this undesired re-styling.

This can be accomplished with the following replacement rule:

 Style[obj_, {GrayLevel[0]}] :> obj

Complete:

totals4 = {{1093, "AUSTRALIA"}, {235, "BELGIUM"}, {474, "BERMUDA"}, {187, "BRAZIL"}};

BarChart[#, ChartStyle -> "Pastel", 
    ChartLabels -> (Placed[Rotate[#, Pi/3] & /@ #2, {{.5, 0}, {1, 1}}])] & @@ 
  Transpose[totals4] /. Style[obj_, {GrayLevel[0]}] :> obj

enter image description here

The rule may need to be change for the output in other Mathematica versions, or it may need to be made more specific if you have other objects with an explicit style of {GrayLevel[0]} in the chart. An example of a more restrictive pattern that might be needed is:

Text[Style[obj_, {GrayLevel[0]}], pos__] :> Text[obj, pos]

At least in version 7 the underlying Graphics expression that is produced by BarChart is highly conducive to a post-processing approach.

  • Each bar and label is contained in an expression that also includes style information.

  • The label however has an additional Style wrapper to effectively reset the color.

  • To style the bars and labels similarly we need only to remove this undesired re-styling.

This can be accomplished with the following replacement rule:

 Style[obj_, {GrayLevel[0]}] :> obj

Complete:

totals4 = {{1093, "AUSTRALIA"}, {235, "BELGIUM"}, {474, "BERMUDA"}, {187, "BRAZIL"}};

BarChart[#, ChartStyle -> "Pastel", 
    ChartLabels -> (Placed[Rotate[#, Pi/3] & /@ #2, {{.5, 0}, {1, 1}}])] & @@ 
  Transpose[totals4] /. Style[obj_, {GrayLevel[0]}] :> obj

enter image description here

The rule may need to be change for the output in other Mathematica versions, or it may need to be made more specific if you have other objects with an explicit style of {GrayLevel[0]} in the chart. An example of a more restrictive pattern that might be needed is:

Text[Style[obj_, {GrayLevel[0]}], pos__] :> Text[obj, pos]

For Version 7

In version 7 the underlying Graphics expression that is produced by BarChart is highly conducive to a post-processing approach.

  • Each bar and label is contained in an expression that also includes style information.

  • The label however has an additional Style wrapper to effectively reset the color.

  • To style the bars and labels similarly we need only to remove this undesired re-styling.

This can be accomplished with the following replacement rule:

 Style[obj_, {GrayLevel[0]}] :> obj

Complete:

totals4 = {{1093, "AUSTRALIA"}, {235, "BELGIUM"}, {474, "BERMUDA"}, {187, "BRAZIL"}};

BarChart[#, ChartStyle -> "Pastel", 
    ChartLabels -> (Placed[Rotate[#, Pi/3] & /@ #2, {{.5, 0}, {1, 1}}])] & @@ 
  Transpose[totals4] /. Style[obj_, {GrayLevel[0]}] :> obj

enter image description here

The rule may need to be made more specific if you have other objects with an explicit style of {GrayLevel[0]} in the chart. An example of a more restrictive pattern that might be needed is:

Text[Style[obj_, {GrayLevel[0]}], pos__] :> Text[obj, pos]
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

At least in version 7 the underlying Graphics expression that is produced by BarChart is highly conducive to a post-processing approach.

  • Each bar and label is contained in an expression that also includes style information.

  • The label however has an additional Style wrapper to effectively reset the color.

  • To style the bars and labels similarly we need only to remove this undesired re-styling.

This can be accomplished with the following replacement rule:

 Style[obj_, {GrayLevel[0]}] :> obj

Complete:

totals4 = {{1093, "AUSTRALIA"}, {235, "BELGIUM"}, {474, "BERMUDA"}, {187, "BRAZIL"}};

BarChart[#, ChartStyle -> "Pastel", 
    ChartLabels -> (Placed[Rotate[#, Pi/3] & /@ #2, {{.5, 0}, {1, 1}}])] & @@ 
  Transpose[totals4] /. Style[obj_, {GrayLevel[0]}] :> obj

enter image description here

The rule may need to be change for the output in other Mathematica versions, or it may need to be made more specific if you have other objects with an explicit style of {GrayLevel[0]} in the chart. An example of a more restrictive pattern that might be needed is:

Text[Style[obj_, {GrayLevel[0]}], pos__] :> Text[obj, pos]