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

  • $\begingroup$ Since you said Frome->True then you need to use just FrameTicks not Ticks. $\endgroup$ – Nasser Mar 24 '14 at 0:25
  • $\begingroup$ 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. $\endgroup$ – Damian Manda Mar 24 '14 at 0:30
  • $\begingroup$ 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. $\endgroup$ – Nasser Mar 24 '14 at 0:39
  • $\begingroup$ @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) $\endgroup$ – Kuba Mar 25 '14 at 5:50

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

  • $\begingroup$ 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. $\endgroup$ – Damian Manda Mar 25 '14 at 5:51
  • $\begingroup$ @DamianManda Agree. Just set the size as you want. You can use Rasterize at the end to conver it to bitmap. $\endgroup$ – Kuba Mar 25 '14 at 6:07

Here is a solution that doesn't use Overlay, making the result still a Graphics object.

Using the function extraAxisPlot, defined in this post, you get

 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.


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.


  • $\begingroup$ 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. $\endgroup$ – Nasser Mar 24 '14 at 1:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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