12
$\begingroup$

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?

$\endgroup$

1 Answer 1

11
$\begingroup$

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

$\endgroup$
3
  • $\begingroup$ 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? $\endgroup$ Jan 17, 2013 at 4:45
  • $\begingroup$ Does this work for all things such as Plot that produce GraphicsBox FE objects or only Graphics created directly? $\endgroup$
    – Mr.Wizard
    Jan 17, 2013 at 7:34
  • 1
    $\begingroup$ @Mr.Wizard This only works for Graphics created directly. Mike Honeychurch has a great answer here. $\endgroup$
    – Szabolcs
    Nov 11, 2013 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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