[haskell-gnuplot] How to set options for individual lines?
badmofo6662004 at yahoo.com
Tue Oct 5 16:48:38 EDT 2010
Thanks. Exactly what I was trying to do.
From: Henning Thielemann <thunderbird at henning-thielemann.de>
To: John Smith <badmofo6662004 at yahoo.com>
Cc: gnuplot at projects.haskell.org
Sent: Tue, October 5, 2010 1:05:52 PM
Subject: Re: [haskell-gnuplot] How to set options for individual lines?
John Smith wrote:
> I'm using the advanced interface like the demo shows. Here's the function I'm
>using to plot functions:
> plot1VarFunctions :: [(Double -> Double)] -> (Double,Double) -> (Double,Double)
>-> Frame.T (Graph2D.T Double Double)
> plot1VarFunctions functionList domain range =
> let lineSpec =
> Graph2D.lineSpec $
> frameOpts =
> Opts.xRange2d domain $
> Opts.yRange2d range
> in Frame.cons frameOpts $ fmap lineSpec $
> Plot2D.functions Graph2D.lines
> (linearScale 100 domain) functionList
> I would like to be able to pass it a list of tuples (or maybe a list of a
>custom type) that holds functions with their corresponding names, but I can't
>figure out how to change names individually. Setting LineSpec."..." in lineSpec
>changes the names of all the lines.
First I assumed, my gnuplot wrapper had a bug, but now I understand.
I think, what you need is:
[(String, Double -> Double)] ->
(Double,Double) -> (Double,Double) ->
Frame.T (Graph2D.T Double Double)
plot1VarFunctions functionList domain range =
let lineSpec name =
LineSpec.title name $
Opts.xRange2d domain $
in Frame.cons frameOpts $ mconcat $
map (\(name,f) ->
fmap (lineSpec name) $
Plot2D.function Graph2D.lines (linearScale 100 domain) f) $
Demo> Plot.plot X11.cons $ plot1VarFunctions [("sin",sin), ("cos",cos)] (-10,10)
If you need individual specifications for the plotted functions, you cannot use
'Plot2D.functions', but you need multiple calls to 'Plot2D.function'. You can
assemble them using the "mconcat" function from Data.Monoid.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Gnuplot