plots 0.1.0.1 → 0.1.0.2
raw patch · 12 files changed
+66/−60 lines, 12 filesdep ~base
Dependency ranges changed: base
Files
- plots.cabal +2/−1
- src/Diagrams/Coordinates/Isomorphic.hs +2/−1
- src/Diagrams/Coordinates/Polar.hs +1/−1
- src/Plots/Axis/ColourBar.hs +4/−3
- src/Plots/Axis/Render.hs +18/−18
- src/Plots/Axis/Scale.hs +2/−1
- src/Plots/Types.hs +13/−10
- src/Plots/Types/Bar.hs +9/−9
- src/Plots/Types/HeatMap.hs +5/−5
- src/Plots/Types/Histogram.hs +4/−5
- src/Plots/Types/Pie.hs +2/−2
- src/Plots/Types/Scatter.hs +4/−4
plots.cabal view
@@ -1,5 +1,5 @@ name: plots-version: 0.1.0.1+version: 0.1.0.2 synopsis: Diagrams based plotting library. homepage: http://github.com/cchalmers/plots license: BSD3@@ -14,6 +14,7 @@ extra-source-files: README.md diagrams/*.svg extra-doc-files: diagrams/*.svg description: Diagrams based plotting library.+tested-with: GHC==8.0.2, GHC==7.10.3, GHC==7.8.4 source-repository head type: git
src/Diagrams/Coordinates/Isomorphic.hs view
@@ -4,6 +4,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE KindSignatures #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-}@@ -45,7 +46,7 @@ -- | Umbrella class giving everything needed for working in the space. This is -- basically 'V2' or 'V3' from "linear".-type Euclidean v = (HasLinearMap v, HasIndexedBasis v, Metric v)+type Euclidean (v :: * -> *) = (HasLinearMap v, HasIndexedBasis v, Metric v) -- vector like ---------------------------------------------------------
src/Diagrams/Coordinates/Polar.hs view
@@ -160,7 +160,7 @@ instance HasY v => HasY (Point v) where xy_ = lensP . xy_ -instance HasY V2 where xy_ = id+instance HasY V2 where xy_ = _xy instance HasY V3 where xy_ = _xy instance HasY Polar where xy_ = polarV2
src/Plots/Axis/ColourBar.hs view
@@ -38,6 +38,7 @@ ) where import Data.Bool (bool)+import qualified Data.Foldable as F import Data.Typeable import Diagrams.Core.Transform (fromSymmetric) import Diagrams.Prelude hiding (gap)@@ -259,7 +260,7 @@ tickXs' = filter inRange tickXs tks | cbTicks ^. hidden = mempty- | otherwise = foldMap (\x -> aTick # translate (V2 (f x) (-w/2))) tickXs'+ | otherwise = F.foldMap (\x -> aTick # translate (V2 (f x) (-w/2))) tickXs' aTick = someTick (cbTicks ^. majorTicksAlignment) (cbTicks ^. majorTicksLength) someTick tType d = case tType of@@ -271,7 +272,7 @@ gridXs = filter inRange $ view majorGridLinesFunction cbGridLines tickXs bnds gLines | cbGridLines ^. hidden = mempty- | otherwise = foldMap mkGridLine gridXs+ | otherwise = F.foldMap mkGridLine gridXs # strokePath # applyStyle (cbGridLines ^. majorGridLinesStyle) mkGridLine x = mkP2 (f x) (-w/2) ~~ mkP2 (f x) (w/2)@@ -280,7 +281,7 @@ tickLabelXs = view tickLabelFunction cbTickLabels tickXs' bnds tLbs | cbTickLabels ^. hidden = mempty- | otherwise = foldMap drawTickLabel tickLabelXs+ | otherwise = F.foldMap drawTickLabel tickLabelXs drawTickLabel (x,label) = view tickLabelTextFunction cbTickLabels tAlign label # translate v
src/Plots/Axis/Render.hs view
@@ -34,15 +34,15 @@ , buildPlots )where -import Data.Foldable-import Data.Typeable import Data.Bool-import Data.List (sort)+import Data.Foldable as F+import Data.List (sort)+import Data.Typeable import Diagrams.BoundingBox import Diagrams.Prelude import Diagrams.TwoD.Text-import Linear hiding (translation, rotate)+import Linear hiding (rotate, translation) import Diagrams.Backend.CmdLine import Diagrams.Coordinates.Polar@@ -53,8 +53,8 @@ import Plots.Axis.Labels import Plots.Axis.Line import Plots.Axis.Scale-import Plots.Axis.Title import Plots.Axis.Ticks+import Plots.Axis.Title import Plots.Legend import Plots.Style import Plots.Types@@ -381,7 +381,7 @@ -- The lower bound is the maximum distance obtained from the -- envelope trials. We know the radius will be at least this far.- lowerBound = foldr (\v r -> max (f v) r) 0 vs+ lowerBound = F.foldr (\v r -> max (f v) r) 0 vs -- In the worst case, there will be a point at the intersection of -- two neighbouring bounding planes from the envelope calculations.@@ -406,7 +406,7 @@ where r = snd $ boundingRadiusR 30 styledPlots spec = AxisSpec xs t (pure LinearAxis) (a ^. axisColourMap)- plots = foldMap (renderStyledPlot spec) styledPlots+ plots = F.foldMap (renderStyledPlot spec) styledPlots dataBB = fromCorners (mkP2 (-r) (-r)) (mkP2 r r) (xs, tv, t') = calculateScaling (view _Wrapped $ a^.axes.column axisScaling) dataBB@@ -482,11 +482,11 @@ rAxTicks = rAxMajorTicks <> rAxMinorTicks rAxMajorTicks | rA ^. majorTicks . hidden = mempty- | otherwise = foldMap (\x -> rAxMajorTick # translateX x) majorTickRs'+ | otherwise = F.foldMap (\x -> rAxMajorTick # translateX x) majorTickRs' # applyStyle (rA ^. majorTicksStyle) rAxMinorTicks | rA ^. minorTicks . hidden = mempty- | otherwise = foldMap (\x -> rAxMinorTick # translateX x) minorTickRs'+ | otherwise = F.foldMap (\x -> rAxMinorTick # translateX x) minorTickRs' # applyStyle (rA ^. minorTicksStyle) -- The paths used for individual major and minor ticks@@ -510,7 +510,7 @@ rMajorGridLines :: QDiagram b V2 n Any rMajorGridLines | rA ^. majorGridLines . hidden = mempty- | otherwise = foldMap circle (filter (>0) majorGridRs')+ | otherwise = F.foldMap circle (filter (>0) majorGridRs') # applyStyle (rA ^. majorGridLinesStyle) minorGridRs = view minorGridLinesFunction rA minorTickRs (0,r)@@ -518,7 +518,7 @@ rMinorGridLines :: QDiagram b V2 n Any rMinorGridLines | rA ^. minorGridLines . hidden = mempty- | otherwise = foldMap circle (filter (>0) minorGridRs')+ | otherwise = F.foldMap circle (filter (>0) minorGridRs') # applyStyle (rA ^. minorGridLinesStyle) -- Radial tick labels ------------------------------------------------@@ -526,7 +526,7 @@ rAxTickLabels :: QDiagram b V2 n Any rAxTickLabels | rA ^. tickLabel . hidden = mempty- | otherwise = foldMap rDrawTickLabel tickLabelRs+ | otherwise = F.foldMap rDrawTickLabel tickLabelRs -- The positions of the tick labels. tickLabelRs :: [(n, String)]@@ -594,11 +594,11 @@ thetaAxTicks = thetaAxMajorTicks <> thetaAxMinorTicks thetaAxMajorTicks | thetaA ^. majorTicks . hidden = mempty- | otherwise = foldMap (\phi -> thetaAxMajorTick # translateX (s*r) # rotate (phi@@rad)) majorTickThetas'+ | otherwise = F.foldMap (\phi -> thetaAxMajorTick # translateX (s*r) # rotate (phi@@rad)) majorTickThetas' # applyStyle (thetaA ^. majorTicksStyle) thetaAxMinorTicks | thetaA ^. minorTicks . hidden = mempty- | otherwise = foldMap (\phi -> thetaAxMinorTick # translateX (s*r) # rotate (phi@@rad)) minorTickThetas'+ | otherwise = F.foldMap (\phi -> thetaAxMinorTick # translateX (s*r) # rotate (phi@@rad)) minorTickThetas' # applyStyle (thetaA ^. minorTicksStyle) -- The paths used for individual major and minor ticks@@ -623,7 +623,7 @@ thetaMajorGridLines :: QDiagram b V2 n Any thetaMajorGridLines | thetaA ^. majorGridLines . hidden = mempty- | otherwise = foldMap (\phi -> origin ~~ mkP2 r 0 # rotate (phi@@rad)) majorGridThetas'+ | otherwise = F.foldMap (\phi -> origin ~~ mkP2 r 0 # rotate (phi@@rad)) majorGridThetas' # transform t # applyStyle (thetaA ^. majorGridLinesStyle) @@ -632,7 +632,7 @@ thetaMinorGridLines :: QDiagram b V2 n Any thetaMinorGridLines | thetaA ^. minorGridLines . hidden = mempty- | otherwise = foldMap (\phi -> origin ~~ mkP2 r 0 # rotate (phi@@rad)) minorGridThetas'+ | otherwise = F.foldMap (\phi -> origin ~~ mkP2 r 0 # rotate (phi@@rad)) minorGridThetas' # transform t # applyStyle (thetaA ^. minorGridLinesStyle) @@ -641,7 +641,7 @@ thetaAxTickLabels :: QDiagram b V2 n Any thetaAxTickLabels | thetaA ^. tickLabel . hidden = mempty- | otherwise = foldMap thetaDrawTickLabel tickLabelThetas+ | otherwise = F.foldMap thetaDrawTickLabel tickLabelThetas -- The positions of the tick labels. tickLabelThetas :: [(n, String)]@@ -660,7 +660,7 @@ -- line -- | a ^. axisLine . hidden = mempty- -- | otherwise = foldMap mkline (map snd ys) -- merge with ticks?+ -- | otherwise = F.foldMap mkline (map snd ys) -- merge with ticks? -- # transform t -- # stroke -- -- # applyStyle (a ^. axisLine e . axisArrowOpts . _Just . shaftStyle)
src/Plots/Axis/Scale.hs view
@@ -44,6 +44,7 @@ import Data.Default import Data.Distributive import Data.Maybe+import qualified Data.Foldable as F import Diagrams import Linear@@ -282,7 +283,7 @@ -- | Deform an object according to the axis scale. Does nothing for -- linear scales.-logDeform :: (InSpace v n a, Foldable v, Floating n, Deformable a a)+logDeform :: (InSpace v n a, F.Foldable v, Floating n, Deformable a a) => v LogScale -> a -> a logDeform v | allOf folded (== LinearAxis) v = id
src/Plots/Types.hs view
@@ -6,8 +6,8 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE RankNTypes #-}-{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-}@@ -126,18 +126,15 @@ import Control.Monad.State import Data.Bool-import Data.Maybe (fromMaybe)-import Data.Orphans ()+import Data.List (sortBy)+import Data.Maybe (fromMaybe)+import Data.Ord (comparing)+import Data.Orphans () import Data.Typeable-import Data.List (sortOn)-import Diagrams.Prelude as D--#if __GLASGOW_HASKELL__ < 710-import Data.Foldable (Foldable)-#endif+import Diagrams.Prelude as D -import Plots.Style import Plots.Axis.Scale+import Plots.Style import Plots.Util -- Orientation ---------------------------------------------------------@@ -752,4 +749,10 @@ = map (\(_,p,t) -> (p,t)) . sortOn (view _1) . concatMap singleStyledPlotLegend++-- XXX taken from "Data.List", defined here because it was only added in+-- base-4.8 (ghc-7.10)+sortOn :: Ord b => (a -> b) -> [a] -> [a]+sortOn f =+ map snd . sortBy (comparing fst) . map (\x -> let y = f x in y `seq` (y, x))
src/Plots/Types/Bar.hs view
@@ -213,11 +213,11 @@ ------------------------------------------------------------------------ -- | Create equidistant bars using the values.-mkBars :: (Foldable f, Num n) => BarLayout n -> f n -> BarPlot n+mkBars :: (F.Foldable f, Num n) => BarLayout n -> f n -> BarPlot n mkBars bl (F.toList -> ns) = mkFloatingBars bl (map (0,) ns) -- | Create equidistant bars with lower and upper bounds for each bar.-mkFloatingBars :: Foldable f => BarLayout n -> f (n,n) -> BarPlot n+mkFloatingBars :: F.Foldable f => BarLayout n -> f (n,n) -> BarPlot n mkFloatingBars bl (F.toList -> ns) = BarPlot { bpData = ns , bpLayout = bl@@ -321,7 +321,7 @@ barPlot :: (MonadState (Axis b V2 n) m, Plotable (BarPlot n) b,- Foldable f)+ F.Foldable f) => f n -- ^ bar heights -> State (Plot (BarPlot n) b) () -- ^ changes to the bars -> m () -- ^ changes to the 'Axis'@@ -344,7 +344,7 @@ barPlot' :: (MonadState (Axis b V2 n) m, Plotable (BarPlot n) b,- Foldable f)+ F.Foldable f) => f n -- ^ bar heights -> m () -- ^ changes to the 'Axis' barPlot' ns = addPlotable' (mkBars def ns)@@ -368,7 +368,7 @@ namedBarPlot :: (MonadState (Axis b V2 n) m, Plotable (BarPlot n) b,- Foldable f)+ F.Foldable f) => f (String,n) -- ^ bar heights with name -> State (Plot (BarPlot n) b) () -- ^ changes to the bars -> m () -- ^ changes to the 'Axis'@@ -396,7 +396,7 @@ namedBarPlot' :: (MonadState (Axis b V2 n) m, Plotable (BarPlot n) b,- Foldable f)+ F.Foldable f) => f (String,n) -- ^ bar heights with name -> m () -- ^ add plot to the 'Axis' namedBarPlot' ns = namedBarPlot ns (return ())@@ -405,7 +405,7 @@ floatingBarPlot :: (MonadState (Axis b V2 n) m, Plotable (BarPlot n) b,- Foldable f)+ F.Foldable f) => f (n,n) -- ^ bar limits -> State (Plot (BarPlot n) b) () -- ^ changes to the bars -> m ()@@ -580,8 +580,8 @@ multiBars :: (MonadState (Axis b V2 n) m, Plotable (BarPlot n) b,- Foldable f,- Foldable g)+ F.Foldable f,+ F.Foldable g) => f a -- ^ data for multi plot -> (a -> g n) -- ^ extract bar heights from each data set -> State (MultiBarState b n a) () -- ^ state to make changes to the plot
src/Plots/Types/HeatMap.hs view
@@ -110,7 +110,7 @@ -- 'mkHeatMatrix'' :: [['Double']] -> 'HeatMatrix' -- 'mkHeatMatrix'' :: ['Vector' 'Double'] -> 'HeatMatrix' -- @-mkHeatMatrix' :: (Foldable f, Foldable g) => f (g Double) -> HeatMatrix+mkHeatMatrix' :: (F.Foldable f, F.Foldable g) => f (g Double) -> HeatMatrix mkHeatMatrix' xss = HeatMatrix (V2 x y) vd a b where (a,b) = minMax vd@@ -469,8 +469,8 @@ -- > heatMapExample = renderAxis heatMapAxis -- heatMap- :: (Foldable f,- Foldable g,+ :: (F.Foldable f,+ F.Foldable g, TypeableFloat n, Typeable b, MonadState (Axis b V2 n) m,@@ -510,8 +510,8 @@ -- > heatMapExample' = renderAxis heatMapAxis' -- heatMap'- :: (Foldable f,- Foldable g,+ :: (F.Foldable f,+ F.Foldable g, TypeableFloat n, Typeable b, MonadState (Axis b V2 n) m,
src/Plots/Types/Histogram.hs view
@@ -58,7 +58,6 @@ import Control.Monad.State.Lazy import qualified Data.Foldable as F-import Data.Function import Data.Maybe import Data.Typeable @@ -135,7 +134,7 @@ computedHistogram :: (MonadState (Axis b V2 n) m, Plotable (HistogramPlot n) b,- Foldable f)+ F.Foldable f) => n -- ^ start of first bin -> n -- ^ width of each bin -> f n -- ^ heights of the bins@@ -145,7 +144,7 @@ -- | Construct a 'HistogramPlot' from raw histogram data. mkComputedHistogram- :: Foldable f+ :: F.Foldable f => n -- ^ start of first bin -> n -- ^ width of each bin -> f n -- ^ heights of the bins@@ -311,7 +310,7 @@ -- | Create a histogram by binning the data using the -- 'HistogramOptions'. mkHistogramPlot- :: (Foldable f, RealFrac n)+ :: (F.Foldable f, RealFrac n) => HistogramOptions n -> f n -> HistogramPlot n mkHistogramPlot HistogramOptions {..} xs = HistogramPlot@@ -346,7 +345,7 @@ -- | -- mkWeightedHistogram--- :: (Foldable f, OrderdField n)+-- :: (F.Foldable f, OrderdField n) -- => HistogramOptions n -> [(n, n)] -> HistogramPlot n -- mkWeightedHistogram
src/Plots/Types/Pie.hs view
@@ -227,7 +227,7 @@ piePlot :: (MonadState (Axis b Polar n) m, Plotable (Wedge n) b,- Foldable f)+ F.Foldable f) => f a -- ^ data for each wedge -> (a -> n) -- ^ extract weight of each wedge -> State (PieState b n a) ()@@ -265,7 +265,7 @@ piePlot' :: (MonadState (Axis b Polar n) m, Plotable (Wedge n) b,- Foldable f)+ F.Foldable f) => f n -- ^ weight of each wedge -> m () piePlot' ns = piePlot ns id (return ())
src/Plots/Types/Scatter.hs view
@@ -115,7 +115,7 @@ renderPlotable s sty (ScatterPlot (ScatterOptions {..})) = markers <> line where- markers = foldMap mk oData # applyMarkerStyle sty+ markers = F.foldMap mk oData # applyMarkerStyle sty -- mk a = marker # transform (oTr a) # applyStyle (oSty a)@@ -137,7 +137,7 @@ -- | Low level construction of 'ScatterOptions'. mkScatterOptions- :: (PointLike v n p, Foldable f, Fractional n)+ :: (PointLike v n p, F.Foldable f, Fractional n) => f a -> (a -> p) -> ScatterOptions v n a@@ -377,7 +377,7 @@ MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b, Typeable n,- Foldable f)+ F.Foldable f) => f (n, p) -- ^ fold over points with a size -> State (Plot (BubbleOptions v n) b) () -- ^ changes to the options -> m () -- ^ add plot to 'Axis'@@ -393,7 +393,7 @@ Typeable n, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b,- Foldable f)+ F.Foldable f) => f (n, p) -- ^ fold over points with a size -> m () -- ^ add plot to 'Axis' bubblePlot' xs = bubblePlot xs (return ())