Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to have rounded ticks in my Mathematica plots. They look much better for thick frames

Plot[ {Sin[x], Cos[x]}, {x, 0, 3 Pi}, Frame -> True, FrameStyle -> Directive[Black, Thick]]

gives plot with square tick ends

but I would like to round them, to get something like

plot with round tick ends

There is a function CapForm["Round"] but it is not clear how to use it with plots.

share|improve this question
Related:… – eldo Sep 4 '14 at 16:25
up vote 14 down vote accepted

Here is another approach which is based on converting the plot to PDF format first. It makes the tick marks accessible as regular Graphics objects. Specifically, they (and the frame) show up as open JoinedCurve that can be identified by pattern matching. That leads to the following:

p = Plot[{Sin[x], Cos[x]}, {x, 0, 3 Pi}, Frame -> True, 
   FrameStyle -> Directive[Black, Thick]];

First@ImportString[ExportString[p, "PDF"], "PDF"] /. 
 JoinedCurve[{{{0, 2, 0}}}, x_, 
   CurveClosed -> {0}] :> {CapForm["Round"], 
   JoinedCurve[{{{0, 2, 0}}}, x, CurveClosed -> {0}]}


What I did here is to replace the identified curves by wrapping them in {CapForm["Round"], ...}. This will affect all straight lines, including the frame itself (but the frame doesn't have end points because the corners overlap anyway). The plot lines themselves are not affected by the rounding because they aren't straight lines.

The advantage of this approach is that you don't have to manually calculate and specify the tick positions: the ticks will be modified in post-processing without changing their positions. The disadvantage is that the ticks in the resulting plot can no longer be modified by changing the options with Show, because they are "baked in".

share|improve this answer
Just wonderful. I'll spend the next hours playing with your answer :) – eldo Sep 4 '14 at 18:21
(+1) Nice! There is built-in FullGraphics function designed exactly for the purpose you achieve (in a hackish way) with Import[Export[...]] but unfortunately its support seems to be dropped since at least version 5. Export to PDF rounds all the coordinates to 16-bit precision and the Imported plot will have lesser accurate positioning of the graphical primitives than the original plot (though it is still sufficient for the most purposes). – Alexey Popkov Sep 5 '14 at 14:40
@AlexeyPopkov Yes, that's right. But FullGraphics was never reliable. And when you're talking about plots with ticks etc., I think we can assume that a reduction to 16-bit precision will be visually imperceptible. This precision issue is indeed important when your goal is to use the vector graphics in some other high-res operation later. Then I don't think one would want a frame and ticks in the first place, though. – Jens Sep 5 '14 at 16:51

I'm afraid you will have to build your own graphic primitives. Something like this:

 Plot[Sin[x], {x, 0, 5}],
 Graphics[{GrayLevel[0.3], Table[Disk[{n, 0}, {0.025, 0.04}, {0, Pi}], {n, 0, 5}]}],
 ImageSize -> 600]

enter image description here

share|improve this answer

Your Answer


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.