7
$\begingroup$

I want to check if this is a bug before I email WR about it.

I can't get ListPlot[] to make scatter plots over a very small area:

n = 40;
c = I + RandomReal[1, n]*(2^-48)*Exp[I*Pi*2*RandomReal[1, n]];
ListPlot[Transpose[{Re[c], Im[c]}]]

BadScatterPlot

Providing an explicit PlotRange returns the exact same plot:

ListPlot[Transpose[{Re[c], Im[c]}], PlotRange -> {{Min[Re[c]], Max[Re[c]]}, {Min[Im[c]], Max[Im[c]]}}]

Subtracting I from c as a workaround yields a plot, but I shouldn't have to do this:

ListPlot[Transpose[{Re[c], Im[c - I]}]]

cMinusI

Is this a bug, or is there some quirk of ListPlot[] that I'm not aware of? Thanks.

$\endgroup$
8
  • $\begingroup$ At least when I try this, Im[c] evaluates to 1.0 for all c. Are you sure you're not in some sort of machine-precision-limited situation here? $\endgroup$
    – flip
    Jan 22, 2016 at 1:03
  • $\begingroup$ @flip Is it just displaying as 1? Try subtracting 1 from Im[c], and try Im[c-i]. This this was just a precision error, my second plot would fail. $\endgroup$ Jan 22, 2016 at 1:08
  • $\begingroup$ In short, Im[c] - I is a complex number, however you may probably want to plot this: Im[c-I]. $\endgroup$
    – luyuwuli
    Jan 22, 2016 at 6:40
  • $\begingroup$ +1. Except for the typo of the input, it's a valuable question. Since 2^-48 > 2^-53, there is no reason for the lost of the precision. The plot range issue also happens to Plot etc.. Quite weird. $\endgroup$
    – luyuwuli
    Jan 22, 2016 at 7:34
  • $\begingroup$ @luyuwuli Thank you. But what typo in the input? Did you fix it? $\endgroup$ Jan 22, 2016 at 7:38

1 Answer 1

2
$\begingroup$

This is a feature of ListPlot. It tries to avoid generating graphics where all the ticks would look the same ("1", in this case.)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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