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.

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 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 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 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 at 5:50

2 Answers 2

up vote 3 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}]},

 Overlay@{

   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 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 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.

plot

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 at 1: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.