[haskell-gnuplot] handling missing data: do not connect points with missing data in between
Henning Thielemann
lemming at henning-thielemann.de
Sat Feb 9 18:33:55 GMT 2013
On Sat, 9 Feb 2013, Daniel Seidel wrote:
> gnuplot again made it very easy to do great plots. But for my current needs,
> a very little nasty difference between what I want and what I get remains:
>
> I've got lists of Floats with NaN inside (that is intended that way) and plot
> them with
>
> plotListsStyle :: C a => [Attribute] -> [(PlotStyle, [a])] -> IO ()
>
> using PlotType LinesPoints for all lists.
>
> My intention is to connect consecutive points, but if there is a NaN in
> between, the points should not get connected. Unfortunately, they get
> connected.
I don't know whether gnuplot supports this function natively, but I think
it is easier to solve this in Haskell. You could cut the list at the NaNs
and plot the sub-lists. However you would need to resort to plotPaths.
import qualified Data.List.HT as ListHT
plotPathsStyle ... $
filter (not . null) $
map (dropWhile (isNaN . snd)) $
ListHT.segmentBefore (isNaN . snd) $ zip [0..] xs
More information about the Gnuplot
mailing list