-
Notifications
You must be signed in to change notification settings - Fork 85
example 1
Jan Bracker edited this page Aug 26, 2013
·
10 revisions
This chart:
was produced by this code:
import System.Environment(getArgs)
import Graphics.Rendering.Chart
import Data.Colour
import Data.Colour.Names
import Data.Default.Class
import Graphics.Rendering.Chart.Backend.Cairo
import Control.Lens
chart = toRenderable layout
where
am :: Double -> Double
am x = (sin (x*3.14159/45) + 1) / 2 * (sin (x*3.14159/5))
sinusoid1 = plot_lines_values .~ [[ (x,(am x)) | x <- [0,(0.5)..400]]]
$ plot_lines_style . line_color .~ opaque blue
$ plot_lines_title .~ "am"
$ def
sinusoid2 = plot_points_style .~ filledCircles 2 (opaque red)
$ plot_points_values .~ [ (x,(am x)) | x <- [0,7..400]]
$ plot_points_title .~ "am points"
$ def
layout = layout1_title .~ "Amplitude Modulation"
$ layout1_plots .~ [Left (toPlot sinusoid1),
Left (toPlot sinusoid2)]
$ def
main1 ["small"] = renderableToPNGFile chart 320 240 "example1_small.png"
main1 ["big"] = renderableToPNGFile chart 800 600 "example1_big.png"
main = getArgs >>= main1