3

I am running Mathematica 7. Suppose that I plot $\sin(x)$ for $x = 0..10$ and frame the plot using Frame -> True:

Plot[Sin[x], {x, 0, 10}, PlotRange -> All, Frame -> True]

Plot 1

Now suppose that I would like the horizontal axis to have ticks every $0.5$ (which it does), but with the ticks labeled only every $1$. Is there a way to do this?

FrameTicks seemed to be a possibility, but when I used Range[0, 10, 1] in the bottom horizontal axis specification, I lost the (non-labeled) ticks at every $0.5$:

Plot[Sin[x], {x, 0, 10}, PlotRange -> All, Frame -> True, 
 FrameTicks -> {{Automatic, Automatic}, {Range[0, 10, 1], Automatic}}]

Plot 2

Thanks for your time.

Andrew
  • 10,569
  • 5
  • 51
  • 104

1 Answers1

8

Using kguler's comment (thank you!), I get the following, which is the output I was looking for:

Plot[Sin[x], {x, 0, 10}, PlotRange -> All, Frame -> True, 
 FrameTicks -> {{Automatic, Automatic}, 
  {Join[Range[0, 10], Thread[{Range[0.5, 10, 1], " "}]], Automatic}}]

Plot 3

Andrew
  • 10,569
  • 5
  • 51
  • 104
  • 3
    you can control the labels,positions and styling of ticks more finely using the second, third and fourth arguments. Try, for example, Frameticks-> {{Automatic, Automatic}, {Join[{#, #, {.01, 0}} & /@ Range[0, 10], {#, " ", {.0075, 0}, Directive[Red, Thick]} & /@ Range[0.5, 10, 1.]], Automatic}}. (+1) – kglr Jan 14 '13 at 22:56