-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathBierEtAlChart.hs
134 lines (112 loc) · 4.42 KB
/
BierEtAlChart.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{-# 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 BierEtAlChart (
diag
, diagSmooth
, diagFitted
) where
import Graphics.Rendering.Chart
import Graphics.Rendering.Chart.Backend.Diagrams
import Diagrams.Backend.Cairo.CmdLine
import Diagrams.Prelude hiding ( render, Renderable )
import System.IO.Unsafe
denv :: DEnv Double
denv = unsafePerformIO $ defaultEnv vectorAlignmentFns 600 500
diag :: String ->
[(Double, Double)] ->
[(Double, Double)] ->
Diagram Cairo
diag t l xs =
fst $ runBackend denv (render (chart t l xs) (600, 500))
chart :: String ->
[(Double, Double)] ->
[(Double, Double)] ->
Renderable ()
chart t l obs = toRenderable layout
where
boundry = plot_lines_values .~ [l]
$ plot_lines_style . line_color .~ opaque red
$ plot_lines_title .~ "ATP"
$ plot_lines_style . line_width .~ 1.0
$ def
actuals = plot_points_values .~ obs
$ plot_points_style . point_color .~ opaque blue
$ plot_points_title .~ "Glucose"
$ def
layout = layout_title .~ t
$ layout_plots .~ [toPlot actuals, toPlot boundry]
$ layout_y_axis . laxis_title .~ "y co-ordinate"
$ layout_y_axis . laxis_override .~ axisGridHide
$ layout_x_axis . laxis_title .~ "x co-ordindate"
$ layout_x_axis . laxis_override .~ axisGridHide
$ def
diagFitted :: String ->
[(Double, Double)] ->
[(Double, Double)] ->
[(Double, Double)] ->
Diagram Cairo
diagFitted t l xs es =
fst $ runBackend denv (render (chartFitted t l xs es) (600, 500))
chartFitted :: String ->
[(Double, Double)] ->
[(Double, Double)] ->
[(Double, Double)] ->
Renderable ()
chartFitted t l obs ests = toRenderable layout
where
boundry = plot_lines_values .~ [l]
$ plot_lines_style . line_color .~ opaque red
$ plot_lines_title .~ "Actual Trajectory"
$ plot_lines_style . line_width .~ 1.0
$ def
estimas = plot_lines_values .~ [ests]
$ plot_lines_style . line_color .~ opaque green
$ plot_lines_title .~ "Inferred Trajectory"
$ plot_lines_style . line_width .~ 1.0
$ def
actuals = plot_points_values .~ obs
$ plot_points_style . point_color .~ opaque blue
$ plot_points_title .~ "Measurements"
$ def
layout = layout_title .~ t
$ layout_plots .~ [toPlot actuals, toPlot boundry, toPlot estimas]
$ layout_y_axis . laxis_title .~ "y co-ordinate"
$ layout_y_axis . laxis_override .~ axisGridHide
$ layout_x_axis . laxis_title .~ "x co-ordindate"
$ layout_x_axis . laxis_override .~ axisGridHide
$ def
chartSmooth :: String ->
[(Double, Double)] ->
[[(Double, Double)]] ->
Renderable ()
chartSmooth t l obss = toRenderable layout
where
boundry = plot_points_values .~ l
$ plot_points_title .~ "Actual"
$ plot_points_style .~ filledCircles 4 (red `withOpacity` 0.25)
$ def
actuals obs = plot_points_values .~ obs
$ plot_points_style .~ filledCircles 2 (blue `withOpacity` 0.25)
$ def
paths = plot_lines_values .~ obss
$ plot_lines_style . line_color .~ (green `withOpacity` 0.1)
$ plot_lines_title .~ "Particle Trajectories"
-- $ plot_lines_style . line_width .~ 1.0
$ def
layout = layout_title .~ t
$ layout_plots .~ (toPlot paths) : (toPlot boundry) : (map (toPlot . actuals) obss)
$ layout_y_axis . laxis_title .~ "Position"
$ layout_y_axis . laxis_override .~ axisGridHide
$ layout_x_axis . laxis_title .~ "Time"
$ layout_x_axis . laxis_override .~ axisGridHide
$ def
diagSmooth :: String ->
[(Double, Double)] ->
[[(Double, Double)]] ->
Diagram Cairo
diagSmooth t l xss =
fst $ runBackend denv (render (chartSmooth t l xss) (600, 500))