Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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 have a plot where I would like ticks shown on both the axes and the frame, with them labeled separately. I have custom labels for the frame and want the horizontal axis labeled with ticks automatically. Despite setting both the Ticks and the Frame properties, I cannot get the ticks to show up on the axes. Is there a way to do this without drawing the ticks manually or something like that? My example is shown below, I am able to get automatic ticks on the top of the frame, but these are not labeled either.

Plot[xt[t], {t, 0, .5*10^-3}, 
  Ticks -> Automatic, 
  FrameLabel -> {{"x [m]", None}, {"t", None}},
  Frame -> True,
  FrameTicks -> {{Automatic, None}, {{{0, "t'"}, {.0005, "t'+5 ms"}}, Automatic}}]

Plot with no axes ticks

share|improve this question
Since you said Frome->True then you need to use just FrameTicks not Ticks. – Nasser Mar 24 '14 at 0:25
Right, I have FrameTicks, as shown in the example, but I also want (different) ticks on the axes line in the middle of the graph. – Damian Manda Mar 24 '14 at 0:30
I understand that what you wanted, but when Frame->True then Ticks is ignored and not even looked at. So there is no point of even having it there. That is what I mean. Try Plot[Sin[x], {x, -Pi, Pi}, Frame -> True, Ticks -> {{1, 1}}] so the actual ticks will have to come from FrameTicks which you already specified. – Nasser Mar 24 '14 at 0:39
@DamianManda Thanks for the accept. Notice that you can also upvot all the answers you find useful. (with that gray triangle next to each answer) – Kuba Mar 25 '14 at 5:50
up vote 7 down vote accepted

As noticed in this topic it is impossible an could be confusing. The solution is as usual, Overlay :)

With[{opt = Sequence[ImagePadding -> {{65, 25}, {40, 15}}, BaseStyle -> {Bold, 15}]},


   Plot[Sin[t], {t, 0, 2 Pi}, FrameLabel -> {{"x [m]", ""}, {"t", ""}}, Frame -> True, 
    FrameTicks -> {{Automatic, None}, {{{0, "t'"}, {2 Pi, "t'+5 ms"}}, Automatic}}, 
    Axes -> False, opt],

   Plot[Sin[t], {t, 0, 2 Pi}, Axes -> {True, False}, PlotStyle -> None, opt]

enter image description here

share|improve this answer
Thanks, this is what I was looking for. I realize it can be confusing in some circumstances but wanted it for this case. In case anyone else also wants to then resize the plot (it doesn't have handles), you can add ImageSize->Large to the opt sequence. – Damian Manda Mar 25 '14 at 5:51
@DamianManda Agree. Just set the size as you want. You can use Rasterize at the end to conver it to bitmap. – Kuba Mar 25 '14 at 6:07

Since you do not provide a definition for x[t], I can't reproduce your plot, but maybe the following code will suggest a work-around that you will find satisfactory.

Plot[Sin[t], {t, 0, 2. Pi},
  Frame -> True,
  FrameLabel -> {{"x [m]", None}, {"t", None}}, 
  FrameTicks -> {{Automatic, None}, {{{0, "0"}, {Pi, "π"}, {2 Pi, "2\[ThinSpace]π"}}, All}}] 

As you can see, changing the specification of the top ticks from Automatic to All makes the default labeling visible.


share|improve this answer
I assumed they wanted on the lower x-axis the same ticks as the top axis (i.e more ticks), but in addition to add those 2 edges special tick labels they had. (you are right, it would have been better to have xt[t] there also). may be OP can clarify. – Nasser Mar 24 '14 at 1:24

@Kuba's solution solved OP's problem, but I thought I would give an answer that doesn't use Overlay. Mainly I dislike Overlay because the result is not a Graphics object. Overlay essentially needs to be the last step, because you can't combine the result with anything else using Show or the like.

Using the function extraAxisPlot, defined in this post, you get (here I'm guessing at your function)

 Plot[Sin[10^5 t] (.7 10^-3 - t), {t, 0, .5*10^-3},
  Ticks -> Automatic,
  FrameLabel -> {{"x [m]", None}, {"t", None}},
  Frame -> True,
  ImageSize -> 450,
  FrameTicks -> {{Automatic, None}, {{{0, "t'"}, {.0005, "t'+5 ms"}}, 
 {0, .5*10^-3},
 {0, 0}

enter image description here

The arguments to extraAxisPlot are the original plot, the range of the extra axis, and the initial point for it to start at.

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.