profun/app/Plot.hs
2024-05-26 12:52:54 +02:00

16 lines
650 B
Haskell

module Plot where
import Graphics.Rendering.Chart.Easy
import Graphics.Rendering.Chart.Backend.Diagrams
formatData :: Double -> Double -> Double -> [(Int, Double)]
formatData yday tday tmrw = [(0, yday), (1, tday), (2, tmrw)]
generatePlot :: Double -> Double -> Double -> IO ()
generatePlot yday tday tmrw = toFile def "plot/weather.svg" $ do
layout_title .= "Yesterday, Today, and Tomorrow's Temperatures"
layout_margin .= 30
layout_y_axis . laxis_generate .= scaledAxis def (-10, 40)
layout_x_axis . laxis_generate .= autoIndexAxis ["Yesterday", "Today", "Tomorrow"]
plot $ line "Degrees Celsius" [formatData yday tday tmrw]