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

share|improve this question
2  
The CustomTicks package is the way to go, IMHO. –  Guillochon Jan 14 '13 at 22:34
2  
Does FrameTicks -> {{Automatic, Automatic}, {Join[Range[0, 10], Thread[{Range[0.5, 10, 1.], " "}]], Automatic}}] work? –  kguler Jan 14 '13 at 22:37
1  
With the documentation for Frameticks or the results of this search mathematica.stackexchange.com/search?q=frameticks you should have no trouble. –  David Carraher Jan 14 '13 at 22:37
    
@kguler Yes, that indeed does work. Thank you! –  Andrew Jan 14 '13 at 22:46
1  
Here's an example of using CustomTicks. I think you'd end up rewriting the same thing anyway. It saves times to just use CustomTicks and you'll get a prettier output with less work. –  Szabolcs Jan 14 '13 at 23:30
add comment

1 Answer 1

up vote 7 down vote accepted

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

share|improve this answer
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) –  kguler Jan 14 '13 at 22:56
add comment

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.