2
$\begingroup$

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?

$\endgroup$
4
  • $\begingroup$ BaseStyle -> Directive[FontFamily -> "Helvetica"]. This probably should be merged with your previous question. $\endgroup$ Jul 14, 2014 at 9:23
  • $\begingroup$ @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. $\endgroup$
    – stevenvh
    Jul 14, 2014 at 9:27
  • $\begingroup$ @MikeHoneychurch - This doesn't seem to change the font for the legends. $\endgroup$
    – stevenvh
    Jul 14, 2014 at 9:29
  • $\begingroup$ ok. see answer below $\endgroup$ Jul 14, 2014 at 9:35

2 Answers 2

3
$\begingroup$

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.

$\endgroup$
6
  • 4
    $\begingroup$ Trajan? You'll annoy the internets... :) $\endgroup$
    – cormullion
    Jul 14, 2014 at 10:57
  • 2
    $\begingroup$ @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? $\endgroup$
    – Mr.Wizard
    Jul 14, 2014 at 11:00
  • 1
    $\begingroup$ Just pick one from here - lots to choose from... :) $\endgroup$
    – cormullion
    Jul 14, 2014 at 11:08
  • 1
    $\begingroup$ Failure of Directive would be a bug $\endgroup$ Jul 14, 2014 at 20:17
  • $\begingroup$ @MikeHoneychurch I suppose so. No upvote? Isn't at least "This answer is useful?" $\endgroup$
    – Mr.Wizard
    Jul 14, 2014 at 23:47
1
$\begingroup$
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

$\endgroup$
2
  • $\begingroup$ 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. $\endgroup$
    – stevenvh
    Jul 14, 2014 at 9:43
  • $\begingroup$ sorry ChartBaseStyle is redundant in this example. $\endgroup$ Jul 14, 2014 at 9:45

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.