sym-plot 0.1.0 → 0.2.0
raw patch · 2 files changed
+21/−21 lines, 2 filesdep −diagrams-coredep ~basedep ~sym
Dependencies removed: diagrams-core
Dependency ranges changed: base, sym
Files
- Math/Sym/Plot.hs +18/−18
- sym-plot.cabal +3/−3
Math/Sym/Plot.hs view
@@ -1,33 +1,32 @@ {-# LANGUAGE NoMonomorphismRestriction #-} -- |--- Module : Math.Sym.Plot--- Copyright : (c) Anders Claesson 2013--- License : BSD-style+-- Copyright : Anders Claesson 2013 -- Maintainer : Anders Claesson <anders.claesson@gmail.com>--- +-- -- Plot permutations. module Math.Sym.Plot (- plotPerm, plotPerms, savePNG+ Plot, plotPerm, plotPerms, savePlot ) where import Diagrams.Prelude-import Graphics.Rendering.Diagrams.Core-import Diagrams.Backend.Cairo.Internal-import Math.Sym (Perm (..), st, toList, size)+import Diagrams.Backend.Cairo+import Data.Perm (toList)+import Math.Sym -type DC = Diagram Cairo R2+-- | A plot is represented by Cairo diagram+type Plot = Diagram Cairo R2 -- An n x n grid-grid :: Int -> DC+grid :: Int -> Plot grid n = stripes `atop` rotateBy (1/4) stripes where stripes = centerXY . hcat' with {sep = 1} . replicate n . vrule $ fromIntegral n --- | The plot of a permutation as a Cairo diagram.-plotPerm :: Perm a => a -> DC+-- | The plot of a permutation.+plotPerm :: Permutation a => a -> Plot plotPerm w = centerXY plot `atop` grid n `atop` background where n = size w@@ -41,11 +40,12 @@ chunk k [] = [] chunk k xs = ys : chunk k zs where (ys, zs) = splitAt k xs --- | The plot of a list of permutations as a Cairo diagram. The first--- argument specifies how many permutations are on each row.-plotPerms :: Perm a => Int -> [a] -> DC+-- | The plot of a list of permutations. The first argument specifies+-- how many permutations are on each row.+plotPerms :: Permutation a => Int -> [a] -> Plot plotPerms cols = vcat . map hcat . chunk cols . map (pad 1.1 . plotPerm) --- | Save a Cairo diagram as a PNG.-savePNG :: Double -> String -> DC -> IO ()-savePNG width filePath = fst . renderDia Cairo (CairoOptions filePath (Width width) PNG)+-- | Save plot as a png, ps, pdf, or svg (determined automatically from+-- the file extension).+savePlot :: Double -> String -> Plot -> IO ()+savePlot width filePath = renderCairo filePath (Width width)
sym-plot.cabal view
@@ -1,9 +1,9 @@ name: sym-plot-version: 0.1.0+version: 0.2.0 synopsis: Plot permutations; an addition to the sym package description: This packade adds plots to the sym package. It has been factored out- of that package because diagrams is a heavy dependency.+ of that package because diagrams is a rather heavy dependency. homepage: http://github.com/akc/sym-plot license: BSD3@@ -19,5 +19,5 @@ location: git://github.com/akc/sym-plot.git library- build-depends: base ==4.5.*, sym, diagrams-core, diagrams-lib, diagrams-cairo+ build-depends: base >= 3 && <= 4.7, sym >= 0.9, diagrams-lib, diagrams-cairo Exposed-modules: Math.Sym.Plot