Longer ticks without specifying the ticks itself

As pointed out by Virgil in the comments, the CustomTicks package resolved the issue.


In V10, you can use the "TicksLength" option of Charting`ScaledTicks to do this. There is a bug/restriction, discussed in Thickness of logarithmic tick marks, that Charting`ScaledTicks will override tick styling. So myTicks below will override the override and replace the default styling with the style passed to it. There is another difficulty in that Charting`ScaledFrameTicks does not have a "TicksLength" option, so to get unlabeled frame ticks of a desired length, I included that capability in myTicks.

Options[myTicks] = $myTicksOptions = 
   Join[Options[Charting`ScaledTicks], {TicksStyle -> Automatic}];
myTicks[type_, opts : OptionsPattern[]] := 
 With[{stOpts = 
         FilterRules[Flatten[{opts, Options[myTicks]}], Options[Charting`ScaledTicks]],
       tstyle = OptionValue[TicksStyle]},
  Module[{ticks = Charting`ScaledTicks[{Identity, Identity}, stOpts][##]},
    If[type === "Frame", ticks[[All, 2]] = Spacer[{0, 0}]];
    If[tstyle =!= Automatic, ticks[[All, 4]] = tstyle];
    ticks] &]

A few notes on the code: If the type is "Frame", frame-style ticks with no labels will be generated; other values for type result in tick labels (I used Automatic below). Since we're returning a Function, we have to evaluate and inject the current options settings (with With) for them to have effect. ScaledTicks generates a list of ticks of the form {x, label, length, style}. Minor ticks come with Spacer[{0, 0}] as a label, so one could restyle ticks in all sorts of ways

Since we will have to specify all four FrameTicks functions, it is easier to deal with passing the options to myTicks with SetOptions.

SetOptions[myTicks, {"TicksLength" -> {0.03, 0.02}}];
ListPlot[
 Abs@Sin[N[#]] & /@ Range[350], Frame -> True, Joined -> True, 
 PlotRange -> {{35, 300}, {0, 1.05}}, 
 FrameLabel -> 
  (Style[#, 30] & /@ {"T [MeV]", "σ/\!\(\*SubscriptBox[\(σ\), \(0\)]\)"}), 
 FrameStyle -> Thick, 
 FrameTicks -> 
   {{myTicks[Automatic], myTicks["Frame"]}, {myTicks[Automatic], myTicks["Frame"]}}, 
 LabelStyle -> Directive[25, Thick]]
SetOptions[myTicks, $myTicksOptions];

Mathematica graphics

You may want thick ticks:

SetOptions[myTicks, {"TicksLength" -> {0.03, 0.02}, TicksStyle -> Thick}];
ListPlot[Abs@Sin[N[#]] & /@ Range[10], 
 Frame -> True, Joined -> True, PlotRange -> {{1, 10}, {0, 1.05}}, 
 FrameLabel -> 
  (Style[#, 30] & /@ {"T [MeV]", "σ/\!\(\*SubscriptBox[\(σ\), \(0\)]\)"}), 
 FrameStyle -> Thick, LabelStyle -> Directive[25, Thick], 
 FrameTicks ->
   {{myTicks[Automatic], myTicks["Frame"]}, {myTicks[Automatic], myTicks["Frame"]}}]
SetOptions[myTicks, $myTicksOptions];

Mathematica graphics

Tags:

Plotting

Ticks