# Grid changes FrameTicksStyle font size

I have a contour plot that I'm trying to organize into a grid using Grid. But Grid changes the FrameTicksStyle font size of the fractions. How do I prevent this?

ContourPlot[x^2 + y^2, {x, 0, π}, {y, -π, π},
FrameTicks -> {{{-π/2, 0, π/2}, None}, {{}, None}},
FrameTicksStyle -> {Directive[14], Directive[14]}]
Grid[{{%, %}, {%, %}}]


If you're wondering why I'm using Grid instead of GraphicsGrid, it's just way easier for what I'm trying to accomplish.

• But only on the fractions, as far as I can tell. Weird. – Brett Champion Oct 24 '15 at 22:12
• Does GraphicsGrid do the same thing? That allows you to set the size of the image, and the font sizes shouldn't change. Don't have access right now to test however. – march Oct 25 '15 at 3:28
• GraphicsGrid retains the tick marks but adds extra space. – Jack LaVigne Oct 25 '15 at 14:39

Here is something you might use as a work-around.

cp =
ContourPlot[x^2 + y^2, {x, 0, π}, {y, -π, π},
FrameTicks -> {{{{-π/2, "-π/2"}, 0, {π/2, "π/2"}}, None}, {None, None}},
FrameTicksStyle -> {Directive[14], Directive[14]}];
Grid[{{cp, cp}, {cp, cp}}]


• Interesting that this trick doesn't work if you try to use "proper" formatting on the fraction. Seems it's really aimed at not having tall tick numbers. This is definitely useful for my purposes, but I'm gonna leave the question open in case someone has a non-work-around answer. – Max Oct 25 '15 at 5:12

Here is a proper workaround for your problem (which I consider as a nasty bug):

ContourPlot[x^2 + y^2, {x, 0, π}, {y, -π, π},
FrameTicks -> {{{-π/2, 0, π/2}, None}, {{}, None}}, FrameTicksStyle -> 14,
BaseStyle -> {ScriptSizeMultipliers -> 1}]
Grid[{{%, %}, {%, %}}]


Please report this bug to the tech support!

• BaseStyle -> {ScriptSizeMultipliers -> 1} could also be used as an option just for Grid. – Karsten 7. Oct 25 '15 at 15:59
• Super!! Completely unaware of ScriptSizeMultipliers. – Jack LaVigne Oct 26 '15 at 1:42

Grid automatically changes the script level of its contents. This is what you're seeing. All you need to do is to add the option AllowScriptLevelChange->False to your Grid:

ContourPlot[
x^2 + y^2, {x, 0, π}, {y, -π, π},
FrameTicks -> {{{-π/2, 0, π/2}, None}, {{}, None}},
FrameTicksStyle -> {Directive[14], Directive[14]}
]
Grid[
{{%, %}, {%, %}},
AllowScriptLevelChange->False
]


This is an extendion of m_goldberg's answer.

Create the following fraction (Esc pi Esc ctrl-/2)

in your notebook and paste it into the text for the tick label. Then wrap the text in Style and make it size 18. When it shrinks in the grid you will approximately the same size for all of the tick labels.

cp = ContourPlot[x^2 + y^2, {x, 0, π}, {y, -π, π},
FrameTicks -> {{{{-π/2,
Style["\!$$\*FractionBox[\(-π$$, $$2$$]\)", 18]},
0, {π/2,
Style["\!$$\*FractionBox[\(π$$, $$2$$]\)", 18]}},
None}, {None, None}},
FrameTicksStyle -> {Directive[14], Directive[14]}];


and then

Grid[{{cp, cp}, {cp, cp}}]


This is a fair amount of work. If you are doing this a great deal you will probably need to automate it.

• You're gonna like this: ToString[-π/2, StandardForm] // InputForm – J. M.'s torpor Oct 25 '15 at 15:05
• @JackLaVigne Your "solution" creates the opposite problem for cp (without Grid). Also it would be much simpler to write FrameTicks -> {{{{-\[Pi]/2, Style[-\[Pi]/2, 18]}, 0, {\[Pi]/2, Style[\[Pi]/2, 18]}}, None}, {None, None}} what produces the same result. – Alexey Popkov Oct 25 '15 at 15:06