12

In Mathematica 8, I can use GraphicsBoxOptions->{DefaultBaseStyle->{"Graphics", FontFamily -> "Helvetica", FontSize -> 14}} to specify the default font for graphics. But this does not work for Mathematica 9. How to specify the default style in Mathematica 9 then?

Using BaseStyle may be a solution. But it is not generalizable to other default styles like DefaultAxesStyle, DefaultFrameStyle etc. Originally DefaultAxesStyle->{"GraphicsAxes", FontSize -> 12} works in Mathematica 8, but it runs into error in Mathematica 9 (message: The specified setting for the option GraphicsBoxOptions, DefaultAxesStyle cannot be used). Does anyone know about the style specification grammar in Mathematica 9?

rcollyer
  • 33,976
  • 7
  • 92
  • 191
Everett You
  • 2,277
  • 1
  • 17
  • 19

1 Answers1

11

You can set all sorts of options to Graphics using the SetOptions command:

SetOptions[Graphics, 
 BaseStyle -> {FontFamily -> "Helvetica", FontSize -> 16}, 
 AxesStyle -> Directive[Red, Thick]]

The output from this command will show you some other options that you can set. Here I've just set the font style and axes style; FrameStyle can be added as you wish.

(*{AlignmentPoint -> Center, AspectRatio -> Automatic, Axes -> False, 
 AxesLabel -> None, AxesOrigin -> Automatic, 
 AxesStyle -> Directive[RGBColor[1, 0, 0], Thickness[Large]], 
 Background -> None, BaselinePosition -> Automatic, 
 BaseStyle -> {FontFamily -> "Helvetica", FontSize -> 16}, 
 ColorOutput -> Automatic, ContentSelectable -> Automatic, 
 CoordinatesToolOptions -> Automatic, 
 DisplayFunction :> $DisplayFunction, Epilog -> {}, 
 FormatType :> ( ##1 &), Frame -> False, FrameLabel -> None, 
 FrameStyle -> {}, FrameTicks -> Automatic, FrameTicksStyle -> {}, 
 GridLines -> None, GridLinesStyle -> {}, ImageMargins -> 0., 
 ImagePadding -> All, ImageSize -> Automatic, 
 ImageSizeRaw -> Automatic, LabelStyle -> {}, Method -> Automatic, 
 PlotLabel -> None, PlotRange -> All, PlotRangeClipping -> False, 
 PlotRangePadding -> Automatic, PlotRegion -> Automatic, 
 PreserveImageOptions -> Automatic, Prolog -> {}, RotateLabel -> True,
  Ticks -> Automatic, TicksStyle -> {}} *)

This shows that it works:

Graphics[Text["this is a test", {0.5, 0.5}], Axes -> True, 
 ImageSize -> 150]

enter image description here

Verbeia
  • 34,233
  • 9
  • 109
  • 224
  • Thanks for your solution. It solve part of the problem. I also want to modify DefaultAxesStyle and DefaultFrameStyle etc. Do you know how to write the style specification in Mathematica 9? – Everett You Jan 17 '13 at 04:45
  • Does this work for all things such as Plot that produce GraphicsBox FE objects or only Graphics created directly? – Mr.Wizard Jan 17 '13 at 07:34
  • 1
    @Mr.Wizard This only works for Graphics created directly. Mike Honeychurch has a great answer here. – Szabolcs Nov 11 '13 at 12:51