[Haskell-beginners] using withAnnotations from Graphics.Rendering.Plot.Figure

Albert Cardona sapristi at gmail.com
Thu May 22 17:50:10 UTC 2014


Hi all,

given two Vector and a list of strings, I generate a plot of one vector as
a function of the other [1]. At each x,y point, I am trying to place the
corresponding string. For the purpose, I zip3 all three sequences, define
an annotation function, and invoke it with mapM_ in the context of
withAnnotations [2]:


withPlot (1, 1) $ do
...
  let annotation (x, y, label) = text (x + 2, y) (setText label)
    in withAnnotations $ do mapM_ annotation $ zip3 (toList vx) (toList vy)
labels


The code above compiles and runs, the plot shows, but no text annotations
appear at all.

I understand that I am not using the Annote monad correctly: the mapM_
drops every returned value, so the state is not altered.

What is the correct way to invoke withAnnotations over a list of (x, y,
String) ?

Needless to say, I am a beginner in Haskell. Apologies if the above is too
trivial.

Thanks very much in advance.

Albert

[1]
https://github.com/acardona/haskell-lib/blob/master/CATMAID/Analysis/Graph/Plot.hs

[2]
http://hackage.haskell.org/package/plot-0.2.3/docs/Graphics-Rendering-Plot-Figure.html#v:withAnnotations

PS: unfortunately I had sent this message to haskell-cafe; sorry!

-- 
http://albert.rierol.net
http://www.ini.uzh.ch/~acardona/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140522/ea04e673/attachment.html>


More information about the Beginners mailing list