python - Round error when plotting -
i have following array of data:
in [53]: data out[53]: array([ 9.95000000e-05, 9.95000000e-05, 9.95000000e-05, ... ... 9.95000000e-05]) when plot of get:

i expect plot straight line meaningful on y axis. cause behavior?
the problem 9.95000000e-05 9.9500000000000006e-05 or 9.9499999999999979e-05 or simmilar number ipython rounds sake of clarity.
matplotlib, however, acknowledge number in complete precision result has unexpected behaviour.
the workaround or round number values represented in ipython.
in [53]: round(data,7) out[53]: array([ 9.95000000e-05, 9.95000000e-05, 9.95000000e-05, ... ... ]) which provides nice plot:
in [54]: plot(round(data,7)) 
Comments
Post a Comment