Charts – Using Haskell instead of R and Pyplot



Charts – Using Haskell instead of R and Pyplot

0 0


haskell_charts_prezo


On Github zmanian / haskell_charts_prezo

Charts

Using Haskell instead of R and Pyplot

Strengths of Charts

  • Monadic or Pure functional layout and chart contruction
  • Operate a high degree of abstractions
  • Great Examples

Weakness of Charts

  • Non-interactive charting
  • Asethics are fairly utiliarian
  • iHaskell support?

Where do I start?

Backends are seperated from layout

Cairo for PNG. gtk2hs tools need to be your path to build.

Diagrams for SVG

Types

dp :: [Double]
dp = [24,21,32.3,24,15,34,43,55,57,72,74,75,73,72,55,44]

sl :: Sparkline
sl = SparkLine barSpark dp
 
fopt :: FileOptions
fopts = FileOptions (sparkSize sl) PNG
 
main = do
  renderableToFile fopts (sparkLineToRenderable sl) "bar_spark.png"
					

Types

Data.Vector to Renderable ~= R

Helper Functions: Annoying type munging

scatterDataToPointData :: ((V.Vector Double, V.Vector Double, String), Colour a) -> PlotPoints Double Double
scatterDataToPointData ((x_vals,y_vals,title),color) = points (zip (V.toList x_vals) (V.toList y_vals)) title color

zipForHistData :: Double -> [Double]
zipForHistData first = [first]

tupleToPlotVals :: (V.Vector Double) -> [[Double]]
tupleToPlotVals histo = V.toList $ V.map zipForHistData histo

					

Totally worth it!

Applicative data analysis piplines and Math.Statistics