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 want to have axes x on my ListPlot as the range (1,1386), but when I run my code

l =  Table[
   Sum[Binomial[k, j]*j^a*(-1)^(k - j), {j, 0, k}], {k, 1, 1386}];
For[i = 0, i < 3, i++, AppendTo[l, 0]]
m = Table[Sum[Binomial[k, j]*j^b*(-1)^(k - j), {j, 0, k}], {k, 1, 1389}];
p = ((2000^1389)/(2000^1386))*(l/m);
t = Table[
  N[Reduce[ 1/(1 + f) <= p[[i]] <= 1 + f && f >= 0 , f], 100], {i, 1, 
   Length[p]}]
t = Cases[t, Except[False]]
tt = t[[All, 2]]

ListPlot[tt,
    Filling -> Top,
    GridLines -> Automatic,
    PlotStyle -> {Red, PointSize[Large]},
    PlotMarkers -> {Automatic, Medium}, DataRange -> {1, 1386}, 
    AxesLabel -> {k, alpha}]

the plot has range to 1400 (I mean the last number marked on the axes is 1400) How can I fix that to have the last marked value as 1386?

share|improve this question
    
Could you please post tt or the function that generates it? –  István Zachar Jan 6 at 17:03
    
@IstvánZachar Done. To post tt I needed to post another lists of values, so it might be a little messy. –  Ziva Jan 6 at 17:08
1  
Your tt is taking a long time to generate... you should make a minimal working example instead (since your issue is not related to the data, but to the plotting). –  rm -rf Jan 6 at 17:13

1 Answer 1

up vote 2 down vote accepted

You have to specify Ticks for ListPlot (see this), like

...
Ticks -> {Join[Table[n, {n, 1, 1400, 100}], {1386}], Automatic}
....

If I understood your code, you attemped to do something like

t = Table[n, {n, 1, 200}];
ListPlot[t, PlotMarkers -> {Automatic, Medium}, DataRange -> {1, 1386},
 Ticks -> {Join[Table[n, {n, 1, 1400, 100}], {1386}], Automatic}]

list-plot

Note the interplay between DataRange and Ticks.

Hope it helps.

share|improve this answer
    
Your post is great and very helpful. Thanks! –  Ziva Jan 6 at 18:55

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.