2
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ Could you please post tt or the function that generates it? $\endgroup$ – István Zachar Jan 6 '14 at 17:03
  • $\begingroup$ @IstvánZachar Done. To post tt I needed to post another lists of values, so it might be a little messy. $\endgroup$ – Ziva Jan 6 '14 at 17:08
  • 1
    $\begingroup$ 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). $\endgroup$ – rm -rf Jan 6 '14 at 17:13
2
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Your post is great and very helpful. Thanks! $\endgroup$ – Ziva Jan 6 '14 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.