-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathBrownianChart.hs
44 lines (36 loc) · 1.28 KB
/
BrownianChart.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{-# OPTIONS_GHC -Wall #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-type-defaults #-}
{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
{-# OPTIONS_GHC -fno-warn-missing-methods #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module BrownianChart (
diag
) where
import Control.Lens hiding ( (#) )
import Graphics.Rendering.Chart
import Graphics.Rendering.Chart.Backend.Diagrams
import Diagrams.Backend.Cairo.CmdLine
import Diagrams.Prelude hiding ( render, Renderable )
import Data.Default.Class
import System.IO.Unsafe
denv :: DEnv
denv = unsafePerformIO $ defaultEnv vectorAlignmentFns 500 500
diag :: Double -> String ->
[(Double, Double)] ->
Diagram Cairo R2
diag yHt t ls =
fst $ runBackend denv (render (chart yHt t ls) (500, 500))
chart :: Double -> String ->
[(Double, Double)] ->
Renderable ()
chart yHt t lineVals = toRenderable layout
where
actuals = plot_lines_values .~ [lineVals]
$ plot_lines_style . line_color .~ opaque blue
$ plot_lines_style . line_width .~ 5.0
$ def
layout = layout_title .~ t
$ layout_plots .~ [toPlot actuals]
$ layout_y_axis . laxis_generate .~ scaledAxis def (-yHt, yHt)
$ def