Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have this BarChart:

enter image description here

created with this code:

sizes = {10718, 881, 395, 387, 375, 309, 297};
BarChart[sizes, ChartStyle -> 33, ImageSize -> 480, BarOrigin -> Left, ChartLabels -> 
  Placed[sizes, {{1, 0.25}, {0, 0}}, "  " <> ToString[#] <> " kB" &], 
ChartLegends -> {"DelphiXE3", "Delphi2010", "Delphi2005", "Delphi7", 
  "Delphi6", "Delphi5", "Delphi4"}]

Now I want all of the text: ChartLabels, ChartLegends and tick labels in Helvetica. Can I do this with a single property, or do I have to add the property for each of the three elements separately? And how do I either?

share|improve this question
    
BaseStyle -> Directive[FontFamily -> "Helvetica"]. This probably should be merged with your previous question. –  Mike Honeychurch Jul 14 at 9:23
    
@MikeHoneychurch - Thanks again. Not sure about merging; the data is the same, but here it's about the font globally, which wasn't in the other question. –  stevenvh Jul 14 at 9:27
    
@MikeHoneychurch - This doesn't seem to change the font for the legends. –  stevenvh Jul 14 at 9:29
    
ok. see answer below –  Mike Honeychurch Jul 14 at 9:35

2 Answers 2

On its own LabelStyle works for me so long as rules are given as a List, not a Directive.

Minimal example:

BarChart[{1, 2, 3},
 ChartLegends -> {"one", "two", "three"}, 
 LabelStyle -> {FontSize -> 15, FontFamily -> "Trajan Pro"}
]

enter image description here

Your full example chart:

sizes = {10718, 881, 395, 387, 375, 309, 297};

BarChart[sizes,
 ChartStyle -> 33,
 ImageSize -> 480,
 BarOrigin -> Left, 
 ChartLabels -> Placed[sizes, {{1, 0.25}, {0, 0}}, "  " <> ToString[#] <> " kB" &], 
 ChartLegends -> {"DelphiXE3", "Delphi2010", "Delphi2005", "Delphi7", "Delphi6", 
   "Delphi5", "Delphi4"},
 LabelStyle -> {FontSize -> 15, FontFamily -> "Trajan Pro"}
]

enter image description here

Trajan Pro is a distinctive small-caps font I happen to have installed. Substitute Helvetica for deployment.

share|improve this answer
4  
Trajan? You'll annoy the internets... :) –  cormullion Jul 14 at 10:57
2  
@cormullion My only defense is that I was using it before it was overused (I think). Here it merely serves as a distinctive font I have available. I used Comic Sans for that purpose until I saw torches and pitchforks. :o) Got another suggestion for a distinctive font selection, preferably freeware? –  Mr.Wizard Jul 14 at 11:00
1  
Just pick one from here - lots to choose from... :) –  cormullion Jul 14 at 11:08
1  
Failure of Directive would be a bug –  Mike Honeychurch Jul 14 at 20:17
    
@MikeHoneychurch I suppose so. No upvote? Isn't at least "This answer is useful?" –  Mr.Wizard Jul 14 at 23:47
sizes = {10718, 881, 395, 387, 375, 309, 297};
font = "Helvetica";
BarChart[sizes, BaseStyle -> Directive[FontFamily -> font],  
 ChartStyle -> 33, ImageSize -> 480, BarOrigin -> Left, 
 ChartLabels -> 
  Placed[sizes, {{1, 0.25}, {0, 0}}, "  " <> ToString[#] <> " kB" &], 
 ChartLegends -> 
  Placed[{"DelphiXE3", "Delphi2010", "Delphi2005", "Delphi7", 
    "Delphi6", "Delphi5", "Delphi4"}, Right, 
   Style[#, FontFamily -> font] &]]

enter image description here

share|improve this answer
    
Thanks a bunch. I presume the "14" is supposed to change the font size, but it doesn't do anything, not even when I add "FontSize->" in front of it. This did work for the BaseStyle solution you suggested in comment. –  stevenvh Jul 14 at 9:43
    
sorry ChartBaseStyle is redundant in this example. –  Mike Honeychurch Jul 14 at 9:45

Your Answer

 
discard

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.