[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell-cafe
Subject:    [Haskell-cafe] using withAnnotations from Graphics.Rendering.Plot.Figure
From:       Albert Cardona <sapristi () gmail ! com>
Date:       2014-05-22 17:26:29
Message-ID: CAJj13__Mj_Q+r4XXTyh3zGi9oKSrXUWs=dp7sXsxRP7hnWeKvg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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



-- 
http://albert.rierol.net
http://www.ini.uzh.ch/~acardona/

[Attachment #5 (text/html)]

<div dir="ltr">Hi all,<div><br></div><div>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]:</div>

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

<div><br></div><div><br></div><div>The code above compiles and runs, the plot shows, \
but no text annotations appear at all.</div><div><br></div><div>I understand that I \
am not using the Annote monad correctly: the mapM_ drops every returned value, so the \
state is not altered.</div>

<div><br></div><div>What is the correct way to invoke withAnnotations over a list of \
(x, y, String) ?</div><div><br></div><div>Needless to say, I am a beginner in \
Haskell. Apologies if the above is too trivial.</div><div>

<br></div><div>Thanks very much in \
advance.</div><div><br></div><div>Albert</div><div><br></div><div>[1]  <a \
href="https://github.com/acardona/haskell-lib/blob/master/CATMAID/Analysis/Graph/Plot. \
hs">https://github.com/acardona/haskell-lib/blob/master/CATMAID/Analysis/Graph/Plot.hs</a></div>


<div><br></div><div>[2] <a \
href="http://hackage.haskell.org/package/plot-0.2.3/docs/Graphics-Rendering-Plot-Figur \
e.html#v:withAnnotations">http://hackage.haskell.org/package/plot-0.2.3/docs/Graphics-Rendering-Plot-Figure.html#v:withAnnotations</a></div>


<div><br></div><div><br></div><div><br></div>-- <br><a \
href="http://albert.rierol.net" target="_blank">http://albert.rierol.net</a><br><a \
href="http://www.ini.uzh.ch/~acardona/" \
target="_blank">http://www.ini.uzh.ch/~acardona/</a> </div></div>



_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic