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:

enter image description here

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)) 

enter image description here


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -