Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

In a Plot (actually, a Graphics) command, I'd like to make the actual tick marks larger than they are, but I can't find an option to do that. Is there a way?

share|improve this question
1  
You've seen the documentation for Ticks (FrameTicks if you're using frames instead of axes)? Check the tick mark option settings. –  J. M. May 25 '12 at 18:54
1  
Plot[Cos[x], {x, 0, 10}, Ticks -> {{{Pi, 180 [Degree], 1}, {2 Pi, 360 [Degree], 1}, {3 Pi, 540 [Degree], 1}}, {-1, 1}}] –  belisarius May 25 '12 at 18:54
    
@J.M. I did see FrameTicks, but unfortunately that does not seem to work unless I'm using frames (which I cannot in this application). –  rogerl May 25 '12 at 18:58
    
@belisarius That's great, thanks. I hadn't seen that in the documentation. Should work perfectly. –  rogerl May 25 '12 at 19:00

3 Answers 3

up vote 9 down vote accepted

As others notes, if you manually give the ticks specification, it's easy to specify sizes for ticks. But then you need to generate all tick mark positions, including small and big marks, yourself.

Unfortunately, I have never found a way to reliably retrieve the automatically generated ticks specification. While @J.M.'s answer tries to do this, you'll notice that AbsoluteOptions doesn't return exactly the same ticks that were generated automatically.

An often recommended alternative is using the CustomTicks package (I learned about it from @Eli and @R.M.). It is also part of LevelScheme, so I recommend you install the latest version of LevelScheme instead. This package will spare you the pain of implementing your own tick-generator functions.

This is how you could use it:

<< LevelScheme`CustomTicks`

Plot[Sin[x], {x, 0, 10}, Ticks -> LinTicks]

Mathematica graphics

Increase the tick sizes generated by the LinTicks functions:

SetOptions[LinTicks, MajorTickLength -> {0.02, 0}, MinorTickLength -> {0.013, 0}];

Mathematica graphics

Plot[Sin[x], {x, 0, 10}, Ticks -> LinTicks]

Documentation for the package is here.

share|improve this answer
    
While I just started using a variant of Belisarius' answer above, this looks like a great package. Since in my application I want irregular user-specified ticks, I think this should exactly do the trick. Thanks. –  rogerl May 26 '12 at 20:13

Start with

pt = Plot[Sin[x], {x, 0, 2 Pi}]

sine plot

Then, to increase the tick size, try the following:

c = 3; (* scale factor *)
tx = Map[MapAt[c # &, #, 3] &, Ticks /. AbsoluteOptions[pt, Ticks], {2}];
Show[pt, Ticks -> tx]

sine plot with bigger ticks

A similar thing can be done if you're using frames (Frame -> True) instead of axes; for that, you use FrameTicks instead of Ticks. See the docs for more details on those (as well as with AbsoluteOptions[]).

share|improve this answer
    
But this increased the number of tick marks and changed how labels are formatted (6. instead of 6). :-( –  Szabolcs May 26 '12 at 13:05
    
Must be something screwy with AbsoluteOptions[]. (It wasn't this way before.) I assumed it would get exactly the tick styles used. I'll need to think slightly more about this. –  J. M. May 26 '12 at 13:12
    
@Szabolcs: I can't test at the moment; could you try Block[{test = Plot[Sin[x], {x, 0, 2 Pi}]}, GraphicsRow[{test, Show[test, First[AbsoluteOptions[test, Ticks]]]}]] and see what comes up? –  J. M. May 26 '12 at 13:14
1  
Still won't do what it's supposed to. Yes, you are right that there is something wrong with AbsoluteOptions. In 3D it won't even return a tick-list, and in 3D tick sizing is simply broken! When you increase the ImageResolution in Rasterize, ticks don't scale linearly (they scale according to some weird functions...) This prevents me from doing proper antialiasing by upscaling then downscaling. Note how the ticks become near-invisible in the antialiased version in my link. It's because of this, not because lines get thin. –  Szabolcs May 26 '12 at 13:20
1  
There's also something wrong with FullGraphics: it will mess up both ticks and grid lines. I think the reason is that graphics are rendered by the Front End while FullGraphics is just an approximation of this rendering, done by the kernel. You can even read the source of FullGraphics, and find many relics from pre v6 times. What It may be that AbsoluteOptions is broken for the same reason. Why I don't understand is: why would it be necessary that ticks are generated by the front end, not the kernel. One guess is that tick spacing should depend on font sizes, which is know only to the FE –  Szabolcs May 26 '12 at 13:23

From belisarius' comment above:

Plot[Cos[x], 
    {x, 0, 10}, 
    Ticks ->{{{Pi, 180°, .1}, {2 Pi, 360°, .1}, {3 Pi, 540°, .1}}, {-1, 1}}
]

Mathematica graphics

share|improve this answer
    
Note that you can also separately control the length of the two ends of each tick. E.g., in theTicks specification above, replace .1 by {.1,.05} to make the tick stick out twice as far above the x-axis as below the x-axis. –  murray May 26 '12 at 15:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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