Created
February 8, 2014 20:33
-
-
Save DougBurke/8889814 to your computer and use it in GitHub Desktop.
Filled circles not created by Diagrams backend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name: plots | |
Version: 0.1 | |
License: PublicDomain | |
Author: Douglas Burke <dburke.gw@gmail.com> | |
Synopsis: Tests of the Charts library. | |
Description: Tests of the Charts library. | |
Category: Graphics | |
Cabal-Version: >= 1.10 | |
Build-Type: Simple | |
Executable svgplots | |
Build-Depends: | |
base >= 3 && < 5, | |
colour >= 2.2.1 && < 2.4, | |
lens >= 3.9 && < 3.11, | |
data-default-class < 0.1, | |
bytestring >= 0.9 && < 1.0, | |
Chart >= 1.2 && < 1.3, | |
Chart-cairo >= 1.2 && < 1.3, | |
Chart-diagrams >= 1.2 && < 1.3 | |
Main-is: SVGplots.hs | |
Ghc-Options: -threaded -Wall | |
default-language: Haskell2010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import qualified Data.ByteString.Lazy.Char8 as L8 | |
import Graphics.Rendering.Chart | |
import Data.Default.Class | |
import Control.Lens | |
import Data.Colour | |
import Data.Colour.Names | |
import qualified Graphics.Rendering.Chart.Backend.Diagrams as D | |
import qualified Graphics.Rendering.Chart.Backend.Cairo as C | |
testPlot :: Layout Int Int | |
testPlot = | |
let x = [2, 10, 15] | |
y = [10, 2, 20] | |
ps = zip x y | |
asOpenCircle = plot_points_style .~ hollowCircles 6 1 (opaque black) | |
$ plot_points_values .~ ps | |
$ def | |
-- fCol = opaque green | |
fCol = withOpacity green 0.6 | |
asFilledCircle = plot_points_style .~ filledCircles 6 fCol | |
$ plot_points_values .~ ps | |
$ def | |
asLine = plot_lines_style .~ solidLine 1 (opaque orange) | |
$ plot_lines_values .~ [ps] | |
$ def | |
baseLayout = layout_plots .~ [ toPlot asLine | |
, toPlot asFilledCircle | |
, toPlot asOpenCircle | |
] | |
$ def | |
in baseLayout | |
main :: IO () | |
main = do | |
let r = toRenderable testPlot | |
foC = C.FileOptions (600,600) C.SVG | |
outD = "circles-diagrams.svg" | |
outC = "circles-cairo.svg" | |
(svgD, _) <- D.renderableToSVGString r 600 600 | |
L8.writeFile outD svgD | |
putStrLn $ "Created: " ++ outD | |
_ <- C.renderableToFile foC r outC | |
putStrLn $ "Created: " ++ outC | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://gist.github.com/8923417 for the
circles-diagrams.svg
output when a constraint ofdiagrams-core == 0.7.0.1
is added, as suggested in timbod7/haskell-chart#19 (comment)