# Change base font for all graphics objects

How can I change the base font style for all graphics objects, including the ones generated using plotting functions?

I would like to change this a single time and have it affect all graphics generated from there on (i.e. not specify the font on a plot by plot basis).

Say, I'd like to use 16 point Helvetica for everything by default.

My original thought was SetOptions[Graphics, BaseStyle -> {...}], but this will be overridden on graphics created using the various plotting functions (e.g. Plot).

My second try was changing the BaseStyle in the GraphicsBoxOptions of the notebook, but this didn't have an effect.

-
Related: this and this – Simon Woods Nov 11 '13 at 8:58

SetOptions[Graphics, BaseStyle->{FontFamily -> "Helvetica"}]


doesn't work with Plot -- which seems unintuitive.

The styling for graphics is controlled by the Graphics style in the core.nb stylesheet.

We see here that font type and size etc. is explicitly specified so this seems to be taking precedence. For example having a local Graphics style in a private stylesheet with

Cell[StyleData["Graphics"],
GraphicsBoxOptions->{BaseStyle->Directive[FontFamily->"Helvetica",RGBColor[1,0,0],FontSize->16]}]


has no effect. This is analogous to evaluating SetOptions as above.

So if you want to change the base font for all graphics what you need to do is override those specified font styles in the core.nb stylesheet. For example add this to your private stylesheet or to the stylesheet you regularly use.

Cell[StyleData["Graphics"],
FontFamily->"Helvetica",
FontSize->16,
FontWeight->"Plain",
FontColor->RGBColor[1,0,0]]


and you will see it has immediate effect (the pic below is the same cells as the screen grab above. No addition evaluation has taken place. After adding the new Graphics style the fonts automatically change):

-
Are GraphicsBoxOptions part of any stylesheet or is it FrontEnd option, I can't find it. – Kuba Feb 24 at 13:13
@Kuba they can be included as options to any style ...obviously the intended style would be expected to have graphics rendered in the cell – Mike Honeychurch Feb 24 at 22:19
Yes yes, I mean, where are generic GraphicsBoxOptions for e.g. Output inherited from? – Kuba Feb 25 at 5:44
@kuba I do not know. there does not appear to be a parent anywhere – Mike Honeychurch Feb 25 at 6:36

While Mike's answer is of course very nice and useful I'd like to add a very simple Kernel-only idea: Just put all the relevant SetOptions statements into your init.m startup file. This is easily done, once, e.g., like:

Export[
FindFile[
"init.m"], (StringJoin[
"Map[SetOptions[#, BaseStyle \[Rule] {FontFamily->\"Helvetica\", \
FontColor->Red, FontSize->16}]&,\n{",
ExportString[
Riffle[#, ","] &@
ToExpression@
Quiet@Select[
Select[Names[
"System*"], ! StringMatchQ[#, "*Box*" | "\$*"] &], !
FreeQ[Options[Symbol[#]][[All, 1]], BaseStyle] &], "List"],
"}];\n"]
), "Text", CharacterEncoding -> "ASCII"]


This produces (check by FilePrint@FindFile["init.m"] ) :

Map[SetOptions[#, BaseStyle -> {FontFamily->"Helvetica", FontColor->Red, FontSize->16}]&,
,
,
AngularGauge
,
Animate
,
Animator
,
ArrayPlot
,
BarChart
,
BarChart3D
,
BodePlot
,
BooleanGraph
,
BubbleChart
,
BubbleChart3D
,
BulletGauge
,
ButterflyGraph
,
Button
,
ButtonBar
,
CancelButton
,
CandlestickChart
,
CayleyGraph
,
Checkbox
,
CheckboxBar
,
CirculantGraph
,
ClockGauge
,
ColorSetter
,
ColorSlider
,
Column
,
CommunityGraphPlot
,
CompleteGraph
,
CompleteKaryTree
,
ContourPlot
,
ContourPlot3D
,
ControllerManipulate
,
CycleGraph
,
DateListLogPlot
,
DateListPlot
,
DeBruijnGraph
,
DefaultButton
,
DensityHistogram
,
DensityPlot
,
DirectedGraph
,
DiscretePlot
,
DiscretePlot3D
,
DistributionChart
,
Dynamic
,
DynamicModule
,
DynamicNamespace
,
DynamicWrapper
,
FileNameSetter
,
FlipView
,
Framed
,
Graph
,
GraphComplement
,
GraphDifference
,
GraphDisjointUnion
,
Graphics
,
Graphics3D
,
GraphicsArray
,
GraphicsColumn
,
GraphicsGrid
,
GraphicsRow
,
GraphIntersection
,
GraphPlot
,
GraphPlot3D
,
GraphPower
,
GraphUnion
,
Grid
,
GridGraph
,
HararyGraph
,
HighlightGraph
,
Histogram
,
Histogram3D
,
HorizontalGauge
,
HypercubeGraph
,
,
ImageHistogram
,
IncidenceGraph
,
InputField
,
Inset
,
,
Interpretation
,
Item
,
KagiChart
,
KaryTree
,
KirchhoffGraph
,
KnightTourGraph
,
Labeled
,
LabeledSlider
,
LayeredGraphPlot
,
LineBreakChart
,
LineGraph
,
LineIntegralConvolutionPlot
,
ListAnimate
,
ListContourPlot
,
ListContourPlot3D
,
ListCurvePathPlot
,
ListDensityPlot
,
ListLineIntegralConvolutionPlot
,
ListLinePlot
,
ListLogLinearPlot
,
ListLogLogPlot
,
ListLogPlot
,
ListPicker
,
ListPlot
,
ListPlot3D
,
ListPointPlot3D
,
ListPolarPlot
,
ListStreamDensityPlot
,
ListStreamPlot
,
ListSurfacePlot3D
,
ListVectorDensityPlot
,
ListVectorPlot
,
ListVectorPlot3D
,
Locator
,
LocatorPane
,
LogLinearPlot
,
LogLogPlot
,
LogPlot
,
Manipulate
,
MatrixPlot
,
,
MorphologicalGraph
,
Mouseover
,
NeighborhoodGraph
,
NicholsPlot
,
NyquistPlot
,
Opener
,
OpenerView
,
Overlay
,
PairedBarChart
,
PairedHistogram
,
PairedSmoothHistogram
,
Pane
,
Panel
,
PaneSelector
,
ParametricPlot
,
ParametricPlot3D
,
PasteButton
,
PathGraph
,
Periodogram
,
PetersenGraph
,
PieChart
,
PieChart3D
,
Plot
,
Plot3D
,
PointFigureChart
,
PolarPlot
,
Polygon
,
,
PopupView
,
ProbabilityPlot
,
ProbabilityScalePlot
,
ProgressIndicator
,
QuantilePlot
,
,
,
RandomGraph
,
RectangleChart
,
RectangleChart3D
,
RegionPlot
,
RegionPlot3D
,
ReliefPlot
,
RenkoChart
,
ReverseGraph
,
RevolutionPlot3D
,
RootLocusPlot
,
Rotate
,
Row
,
SectorChart
,
SectorChart3D
,
Setter
,
SetterBar
,
SimpleGraph
,
SingularValuePlot
,
Slider
,
Slider2D
,
SlideView
,
SmoothDensityHistogram
,
SmoothHistogram
,
SmoothHistogram3D
,
Spectrogram
,
SphericalPlot3D
,
StarGraph
,
StreamDensityPlot
,
StreamPlot
,
Subgraph
,
TabView
,
Text
,
ThermometerGauge
,
Toggler
,
TogglerBar
,
Tooltip
,
,
TreeForm
,
TreeGraph
,
TreePlot
,
Trigger
,
TuranGraph
,
UndirectedGraph
,
VectorDensityPlot
,
VectorPlot
,
VectorPlot3D
,
VerticalGauge
,
VerticalSlider
,
WaveletImagePlot
,
WaveletListPlot
,
WaveletMatrixPlot
,
WaveletScalogram
,
`