1
$\begingroup$

Please examine the screenshot below. In the first plot, the last point is split into two (?!) erroneous points. The second plot is correct. Can you reproduce/fix the error? ListPlot failure

For your convenience, I add below my Notebook, as exported to a Package

tt={{0,10},{2,60},{4,360},{6,2160},{8,12960},{10,77760},{12,466560}}



ListPlot[tt,Joined->True,PlotStyle->Dashed,Mesh->All,Frame->True,GridLines->Automatic,FrameLabel->{"n","I(t)"}]



tt1={{0,10},{2,60},{4,360},{6,2160},{8,12960},{10,77760},{12,466560},{14,466560}}



ListPlot[tt1,Joined->True,PlotStyle->Dashed,Mesh->All,Frame->True,GridLines->Automatic,FrameLabel->{"n","I(t)"}]
$\endgroup$
  • $\begingroup$ PlotRange -> All seems to fix it. $\endgroup$ – Kuba Aug 11 '18 at 8:15
0
$\begingroup$

Mathematica uses an algorithm to decide what part of the plot contains the most salient features, and chooses the vertical axis range accordingly. This applies unless the user explicitly overrides by specifying the range using the PlotRange option.

So for example, if you enter

Plot[Tan[x], {x, -4 Pi, 4 Pi}]

Mathematica decides where to cut off the plot. If you instead enter

Plot[Tan[x], {x, -4 Pi, 4 Pi}, PlotRange -> {-50, 50}]

you will get a different presentation of the same plot. ListPlot behaves in a similar fashion. Due to the nature of the data you provided in the first plot, Mathematica decided that the $y$-value (ordinate) of the final data point was so much larger than the others that to plot all points to scale would obscure the features of the other data points. But in the second plot, you now have two points with such a value, thus the way the plot changes in this area becomes a feature of interest in itself.

To fix this, you can simply use the option PlotRange -> All .

$\endgroup$
  • $\begingroup$ Thank you heropup. I guessed the problem was with the plot scale. Your hint fixes my problem. $\endgroup$ – Flavio Sartoretto Aug 11 '18 at 16:32

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.