haskell-chart icon indicating copy to clipboard operation
haskell-chart copied to clipboard

Plot handle inputs containing ∞ or NaNs incorrectly

Open Shimuuar opened this issue 8 years ago • 2 comments

If input for plot contains ∞ or NaNs library draws somewhat strange plots. It looks like path is reset and then drawing starts from origin. I'm not sure what is correct behavior in that case. Dropping point and creating gap in the line seems like good idea. Gap makes visible that there's missing point and plot still looks decently

toRenderable
  $ layout_plots .~ 
    [ toPlot ( plot_lines_values .~ [ [(0,1),(1,2),(2,0/0),(3,1),(4,1.5)] ]
             $ def)]
  $ def

download

And real life example download

I'm using cairo backend with ihaskell.

Shimuuar avatar May 17 '16 17:05 Shimuuar

The library used to crash on NaN's so at least this is an improvement :-)

Until now handling of NaN's has been left up to the caller - possibly leaving the points out and breaking the lines as you suggest, though I'd prefer an approach that makes the fact there is a problem more obvious.

timbod7 avatar May 17 '16 21:05 timbod7

O snail
Climb Mount Fuji,
But slowly, slowly!

I would expect that caller being lazy will do simplest and likely dumb thing. So any complicated logic should be bundled into library.

Infinities have very simple interpretation: draw line upward/downward to border of viewport. And infinities are quite common they easily arise in log-scale plots since log 0 = -∞. NaN treatment is more complicated I agree.

Shimuuar avatar May 18 '16 09:05 Shimuuar