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 question about adjusting the number of horizontal tick marks on a 2D plot.

Example:

f[x_] := 4*Sin[4*x]

Plot[{f[x]}, {x, -10, 10}, Ticks -> {Table[Pi n, {n, -5, 5}]}]

Gives the following plot:

enter image description here

How would I go about adding more ticks so I could change the range (in terms of pi) to fractional values of pi?

Say -pi/10 to pi/10

or...in increments of pi/2....or pi/4?

The "Plot" command I am using is one I found from the help because I couldn't figure out how to make the ticks in terms of pi. I'm still learning some of the basics, but I'm quite stuck on changing the # of ticks.

Anyone have some ideas please?

Thanks

share|improve this question
2  
Take a look at Table[Pi n, {n, -5, 5}]. What does it output? What do you need to change to have multiples of Pi/2? –  Szabolcs Feb 11 at 17:40
    
To be honest I don't know what it does. I thought it merely set the number of labels that show on the 'x-axis', but per your post, which I just did not think of, changing those values to -5/2 and 5/2 gives what I'm looking for. Is there an easier ay to accomplish this however? –  fiz Feb 11 at 17:55
2  
Then please start by reading up on Table and understanding what it does and how to use it. Use the documentation. Table is one of the most fundamental constructs in Mathematica and it is quite easy to understand. –  Szabolcs Feb 11 at 17:58
    
Yes, for sure. Up to now it had not come up, but I will look the documentation. Now, your having said that, I asked if there were any other ways to accomplish this task. Is this just one way of doing it, or the easiest? Insight? –  fiz Feb 11 at 18:10
1  
Yes, it's the easiest. For more complex tick arrangements the CustomTicks package is easier, but not for simple ones like what you described. –  Szabolcs Feb 11 at 18:12

1 Answer 1

up vote 2 down vote accepted
Plot[4*Sin[4*x], {x, -10, 10}, 
Ticks -> {Table[Pi/2 n, {n, -15, 15}], Automatic}]

enter image description here

share|improve this answer
    
Thank you santosh. I see what you have done. I thought I tried that and got an error, but I like your method. I will look at it again. –  fiz Feb 11 at 19: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.