# How do I adjust the thickness of all the FrameTicks? [duplicate]

I am very sorry if this is trivial, but I can not for the life of me adjust the thickness of all tick marks in Plots. Depending on the data to plot, either the top, bottom, top and bottom, or top and right ticks stay unaffected. I could not yet find a pattern. Additionally, the ticks look different, depending if I export as PNG or PDF. I need PDF, so I have attached a screenshot of the PDF output.

So, how do I get all the ticks to look like the thicker ones?

Minimal example:

Plot[Sin[x],{x,-7,7},Frame->True,FrameStyle->Thickness[.003],FrameTicksStyle->Thickness[.003]]


My actual example:

ListLinePlot[CaP,
PlotRange->All,
Frame->True,
FrameLabel->{"\[Nu] / cm^-1","Absorption / a. u."},
FrameStyle->Thickness[.003],
LabelStyle->{12},
FrameTicksStyle->{Directive[FontOpacity->0,FontSize->0,Thickness[.003]],Directive[Thickness[.003],Black]},
AspectRatio->1/2,
ScalingFunctions->{"Reverse"},AxesOrigin->{850,0}
]


That is Mathematica 11. Mathematica 10 generates the same output, but the top ticks are as they should be, only the bottom ticks stay unaffected. Same code.

• I think you're doing this correctly in your first example, all the frame ticks should be thick. This is likely a bug. I see the same behavior on OSX v.11.1.1.0 – N.J.Evans Sep 7 '17 at 18:56
• Maybe a duplicate of mathematica.stackexchange.com/q/154092 – m_goldberg Sep 7 '17 at 23:59
• Since the underlying bug is exactly the same as here, I'm voting to close this question as a dupe of that. – Alexey Popkov Sep 8 '17 at 8:53

It seems that the internal functions to create ticks have a hard-coded thickness that overrides the FrameTicksStyle option. You could work around this by modifying this internal function. The easiest way to do so is to use my Initial function, which I reproduce below:

Initial /: Verbatim[TagSetDelayed][Initial[sym_], lhs_, rhs_] := With[
{
new=Block[{sym},
TagSetDelayed[sym,lhs,rhs];
First @ LanguageExtendedDefinition[sym]
],
protect=Unprotect[sym]
},

sym;

Unprotect[sym];
Replace[
new,
Rule[values_,n:Except[{}]] :> (
values[sym] = DeleteDuplicates @ Join[n, values[sym]]
),
{2}
];
Protect@protect;
]


(updated to modify ChartingScaledTicks instead of ChartingScaledFrameTicks so that both ticks with and without numbers are fixed)

The internal function that we need to modify is ChartingScaledTicks:

Initial[ChartingScaledTicks] /:
ChartingScaledTicks[a__][b___] /; !TrueQ@$Fix := Block[{$Fix=True},
ChartingScaledTicks[a][b] /. AbsoluteThickness[.1]->Sequence[]
]


The above just removes the hard-coded AbsoluteThickness[.1]. Now, let's check:

GraphicsRow[{
Plot[
Sin[x],
{x,-7,7},
Frame->True
],
Plot[
Sin[x],
{x,-7,7},
Frame->True,
FrameStyle->AbsoluteThickness[2]
]
}]


• This works for the sine plot, but for my actual example it does not work. The tick marks on the bottom stay unaffected. – Seriouslynothing Sep 8 '17 at 7:16
• I think doing the exact same thing for ChartingScaledTicks instead should fix both of them. – Carl Woll Sep 8 '17 at 7:24
• Yes, that fixed it. Thank you! – Seriouslynothing Sep 8 '17 at 7:50

This issue is exactly the same as in the following question:

Starting from Mathematica 11.1 Plot uses ChartingScaledFrameTicks in the default value for FrameTicks:

Options[Plot[x, {x, 0, 1}], FrameTicks]

{FrameTicks -> {{Automatic, ChartingScaledFrameTicks[{Identity, Identity}]},
{Automatic, ChartingScaledFrameTicks[{Identity, Identity}]}}}


As a result, the bug in ChartingScaledFrameTicks now affects also Plot. The same type of fix is applicable here:

fixTickThickness[gr_] := gr /. f : (_ChartingScaledTicks | _ChartingScaledFrameTicks) :>
(Part[#, ;; , ;; 3] &@*f)


Example:

\$Version

pl = Plot[Sin[x], {x, -7, 7}, Frame -> True, FrameStyle -> AbsoluteThickness[3],
ImageSize -> 400];

Row@{pl, pl // fixTickThickness}

"11.1.1 for Microsoft Windows (64-bit) (April 18, 2017)"


### Update

As it is noted in the comments, the above fix needs to be applied to every plot separately what is tedious. Actually one can make this fix permanent by modifying the default value of DisplayFunction of Plot and other functions affected by this bug:

SetOptions[
Select[Symbol /@ Names["*Plot"], MemberQ[First /@ Options[#], DisplayFunction] &],
DisplayFunction :>
(ReplaceAll[#,
t : (Ticks | FrameTicks -> _) :>
(t /. f : (_ChartingScaledTicks | _ChartingScaledFrameTicks) :>
(Part[#, ;; , ;; 3] &@*f))] &)];


One can add this piece of code to the Kernel's init.m file in order to have it loaded automatically when the Kernel starts. But while this demonstrates another approach to the problem, the solution by Carl Woll is more direct and should be preferable in this concrete case.

• My answer is a one-time fix to ChartingScaledTicks while yours is a post-process step that needs to be done to every plot. – Carl Woll Sep 8 '17 at 15:03
• @CarlWoll Yes, I upvouted your answer before posing mine. Actually it is possible to convert my solution into a on-time fix too, please see the Update section in my answer. – Alexey Popkov Sep 9 '17 at 5:35

It looks like an erroneous FrameTicks rule is being put in the full form. You can get around this by doing the following:

yourPlot=Plot[
Sin[x], {x, -7, 7},
FrameStyle -> Thickness[.003],
Frame -> True,
FrameTicksStyle ->Directive[Thickness[.005]]
];

ToExpression@ToBoxes[
FullForm[yourplot]/.Rule[FrameTicks,_]:>Nothing
]


The one bit of trouble here is that this will also delete any FrameTicks you specify. If you need custom positioned ticks, you can try:

ToExpression@ToBoxes[
FullForm[yourplot]/.Rule[FrameTicks,_]:>Rule[FrameTicks,yourFrameTicks]
]
`

Without fix:

With fix:

• This works, too. Thank you! – Seriouslynothing Sep 8 '17 at 8:31