24 lines
866 B
Haskell
24 lines
866 B
Haskell
module Plot where
|
|
import Graphics.Rendering.Chart.Easy
|
|
import Graphics.Rendering.Chart.Backend.Diagrams
|
|
import System.Process (callCommand)
|
|
|
|
|
|
formatData :: Float -> Float -> Float -> [(Int, Float)]
|
|
formatData yday tday tmrw = [(0, yday), (1, tday), (2, tmrw)]
|
|
|
|
|
|
generatePlot :: Float -> Float -> Float -> 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]
|
|
|
|
|
|
openPlot :: IO ()
|
|
openPlot = callCommand "start plot/weather.svg"
|
|
-- start plot/weather.svg -- Windows
|
|
-- xdg-open plot/weather.svg -- Linux
|
|
-- open plot/weather.svg -- macOS |