plot-light 0.3.1 → 0.3.2
raw patch · 5 files changed
+104/−53 lines, 5 filesdep +data-default-classdep −data-defaultPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: data-default-class
Dependencies removed: data-default
API changes (from Hackage documentation)
- Graphics.Rendering.Plot.Light: (##) :: MultiplicativeSemigroup m => m -> m -> m
- Graphics.Rendering.Plot.Light: (#>) :: LinearMap m v => m -> v -> v
- Graphics.Rendering.Plot.Light: (-.) :: Num a => Point a -> Point a -> V2 a
- Graphics.Rendering.Plot.Light: (.*) :: VectorSpace v => Scalar v -> v -> v
- Graphics.Rendering.Plot.Light: (<.>) :: Hermitian v => v -> v -> InnerProduct v
- Graphics.Rendering.Plot.Light: (<\>) :: MatrixGroup m v => m -> v -> v
- Graphics.Rendering.Plot.Light: (^+^) :: AdditiveGroup v => v -> v -> v
- Graphics.Rendering.Plot.Light: (^-^) :: AdditiveGroup v => v -> v -> v
- Graphics.Rendering.Plot.Light: (~=) :: Eps a => a -> a -> Bool
- Graphics.Rendering.Plot.Light: DMat2 :: a -> a -> DiagMat2 a
- Graphics.Rendering.Plot.Light: Mat2 :: a -> a -> a -> a -> Mat2 a
- Graphics.Rendering.Plot.Light: V2 :: a -> a -> V2 a
- Graphics.Rendering.Plot.Light: class AdditiveGroup v
- Graphics.Rendering.Plot.Light: class Eps a
- Graphics.Rendering.Plot.Light: class VectorSpace v => Hermitian v where {
- Graphics.Rendering.Plot.Light: class Hermitian v => LinearMap m v
- Graphics.Rendering.Plot.Light: class LinearMap m v => MatrixGroup m v
- Graphics.Rendering.Plot.Light: class MultiplicativeSemigroup m
- Graphics.Rendering.Plot.Light: class AdditiveGroup v => VectorSpace v where {
- Graphics.Rendering.Plot.Light: data DiagMat2 a
- Graphics.Rendering.Plot.Light: data Mat2 a
- Graphics.Rendering.Plot.Light: data V2 a
- Graphics.Rendering.Plot.Light: diagMat2 :: Num a => a -> a -> DiagMat2 a
- Graphics.Rendering.Plot.Light: e1 :: Num a => V2 a
- Graphics.Rendering.Plot.Light: e2 :: Num a => V2 a
- Graphics.Rendering.Plot.Light: frameToFrame :: Fractional a => Frame a -> Frame a -> Bool -> Bool -> V2 a -> V2 a
- Graphics.Rendering.Plot.Light: moveLabeledPointBwFrames :: Fractional a => Frame a -> Frame a -> Bool -> Bool -> LabeledPoint l a -> LabeledPoint l a
- Graphics.Rendering.Plot.Light: moveLabeledPointV2 :: Num a => V2 a -> LabeledPoint l a -> LabeledPoint l a
- Graphics.Rendering.Plot.Light: movePoint :: Num a => V2 a -> Point a -> Point a
- Graphics.Rendering.Plot.Light: norm2 :: (Hermitian v, Floating n, n ~ (InnerProduct v)) => v -> n
- Graphics.Rendering.Plot.Light: normalize2 :: (InnerProduct v ~ Scalar v, Floating (Scalar v), Hermitian v) => v -> v
- Graphics.Rendering.Plot.Light: origin :: Num a => Point a
- Graphics.Rendering.Plot.Light: pointRange :: (Fractional a, Integral n) => n -> Point a -> Point a -> [Point a]
- Graphics.Rendering.Plot.Light: type family InnerProduct v :: *;
- Graphics.Rendering.Plot.Light: v2fromEndpoints :: Num a => Point a -> Point a -> V2 a
- Graphics.Rendering.Plot.Light: v2fromPoint :: Num a => Point a -> V2 a
- Graphics.Rendering.Plot.Light: zero :: AdditiveGroup v => v
- Graphics.Rendering.Plot.Light: }
+ Graphics.Rendering.Plot.Light.Internal.Geometry: (##) :: MultiplicativeSemigroup m => m -> m -> m
+ Graphics.Rendering.Plot.Light.Internal.Geometry: (#>) :: LinearMap m v => m -> v -> v
+ Graphics.Rendering.Plot.Light.Internal.Geometry: (-.) :: Num a => Point a -> Point a -> V2 a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: (.*) :: VectorSpace v => Scalar v -> v -> v
+ Graphics.Rendering.Plot.Light.Internal.Geometry: (<.>) :: Hermitian v => v -> v -> InnerProduct v
+ Graphics.Rendering.Plot.Light.Internal.Geometry: (<\>) :: MatrixGroup m v => m -> v -> v
+ Graphics.Rendering.Plot.Light.Internal.Geometry: (^+^) :: AdditiveGroup v => v -> v -> v
+ Graphics.Rendering.Plot.Light.Internal.Geometry: (^-^) :: AdditiveGroup v => v -> v -> v
+ Graphics.Rendering.Plot.Light.Internal.Geometry: (~=) :: Eps a => a -> a -> Bool
+ Graphics.Rendering.Plot.Light.Internal.Geometry: DMat2 :: a -> a -> DiagMat2 a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: Frame :: Point a -> Point a -> Frame a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: LabeledPoint :: Point a -> l -> LabeledPoint l a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: Mat2 :: a -> a -> a -> a -> Mat2 a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: Point :: a -> a -> Point a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: V2 :: a -> a -> V2 a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: X :: Axis
+ Graphics.Rendering.Plot.Light.Internal.Geometry: Y :: Axis
+ Graphics.Rendering.Plot.Light.Internal.Geometry: [_fpmax] :: Frame a -> Point a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: [_fpmin] :: Frame a -> Point a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: [_lp] :: LabeledPoint l a -> Point a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: [_lplabel] :: LabeledPoint l a -> l
+ Graphics.Rendering.Plot.Light.Internal.Geometry: [_px] :: Point a -> a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: [_py] :: Point a -> a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: class AdditiveGroup v
+ Graphics.Rendering.Plot.Light.Internal.Geometry: class Eps a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: class VectorSpace v => Hermitian v where {
+ Graphics.Rendering.Plot.Light.Internal.Geometry: class Hermitian v => LinearMap m v
+ Graphics.Rendering.Plot.Light.Internal.Geometry: class LinearMap m v => MatrixGroup m v
+ Graphics.Rendering.Plot.Light.Internal.Geometry: class MultiplicativeSemigroup m
+ Graphics.Rendering.Plot.Light.Internal.Geometry: class AdditiveGroup v => VectorSpace v where {
+ Graphics.Rendering.Plot.Light.Internal.Geometry: data Axis
+ Graphics.Rendering.Plot.Light.Internal.Geometry: data DiagMat2 a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: data Frame a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: data LabeledPoint l a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: data Mat2 a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: data Point a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: data V2 a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: diagMat2 :: Num a => a -> a -> DiagMat2 a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: e1 :: Num a => V2 a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: e2 :: Num a => V2 a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: frameFromPoints :: (Ord a, Foldable t, Functor t) => t (Point a) -> Frame a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: frameToFrame :: Fractional a => Frame a -> Frame a -> Bool -> Bool -> V2 a -> V2 a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: frameToFrameValue :: Fractional t => Frame t -> Frame t -> t -> t
+ Graphics.Rendering.Plot.Light.Internal.Geometry: height :: Num a => Frame a -> a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance (Data.Default.Class.Default a, GHC.Num.Num a) => Data.Default.Class.Default (Graphics.Rendering.Plot.Light.Internal.Geometry.Frame a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance (Data.Default.Class.Default a, GHC.Num.Num a) => Data.Default.Class.Default (Graphics.Rendering.Plot.Light.Internal.Geometry.MeshGrid a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance (GHC.Classes.Eq l, GHC.Classes.Eq a) => GHC.Classes.Eq (Graphics.Rendering.Plot.Light.Internal.Geometry.LabeledPoint l a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance (GHC.Classes.Ord a, GHC.Num.Num a) => GHC.Base.Monoid (Graphics.Rendering.Plot.Light.Internal.Geometry.Frame a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance (GHC.Show.Show l, GHC.Show.Show a) => GHC.Show.Show (Graphics.Rendering.Plot.Light.Internal.Geometry.LabeledPoint l a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance Data.Default.Class.Default a => Data.Default.Class.Default (Graphics.Rendering.Plot.Light.Internal.Geometry.Point a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Classes.Eq Graphics.Rendering.Plot.Light.Internal.Geometry.Axis
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Classes.Eq a => GHC.Classes.Eq (Graphics.Rendering.Plot.Light.Internal.Geometry.DiagMat2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Classes.Eq a => GHC.Classes.Eq (Graphics.Rendering.Plot.Light.Internal.Geometry.Frame a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Classes.Eq a => GHC.Classes.Eq (Graphics.Rendering.Plot.Light.Internal.Geometry.Mat2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Classes.Eq a => GHC.Classes.Eq (Graphics.Rendering.Plot.Light.Internal.Geometry.MeshGrid a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Classes.Eq a => GHC.Classes.Eq (Graphics.Rendering.Plot.Light.Internal.Geometry.Point a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Classes.Eq a => GHC.Classes.Eq (Graphics.Rendering.Plot.Light.Internal.Geometry.V2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Classes.Ord a => GHC.Classes.Ord (Graphics.Rendering.Plot.Light.Internal.Geometry.Point a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Generics.Generic (Graphics.Rendering.Plot.Light.Internal.Geometry.Frame a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Generics.Generic (Graphics.Rendering.Plot.Light.Internal.Geometry.MeshGrid a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Generics.Generic (Graphics.Rendering.Plot.Light.Internal.Geometry.Point a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Num.Num a => GHC.Base.Monoid (Graphics.Rendering.Plot.Light.Internal.Geometry.DiagMat2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Num.Num a => GHC.Base.Monoid (Graphics.Rendering.Plot.Light.Internal.Geometry.Mat2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Num.Num a => GHC.Base.Monoid (Graphics.Rendering.Plot.Light.Internal.Geometry.V2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Num.Num a => Graphics.Rendering.Plot.Light.Internal.Geometry.AdditiveGroup (Graphics.Rendering.Plot.Light.Internal.Geometry.V2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Num.Num a => Graphics.Rendering.Plot.Light.Internal.Geometry.Hermitian (Graphics.Rendering.Plot.Light.Internal.Geometry.V2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Num.Num a => Graphics.Rendering.Plot.Light.Internal.Geometry.LinearMap (Graphics.Rendering.Plot.Light.Internal.Geometry.DiagMat2 a) (Graphics.Rendering.Plot.Light.Internal.Geometry.V2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Num.Num a => Graphics.Rendering.Plot.Light.Internal.Geometry.LinearMap (Graphics.Rendering.Plot.Light.Internal.Geometry.Mat2 a) (Graphics.Rendering.Plot.Light.Internal.Geometry.V2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Num.Num a => Graphics.Rendering.Plot.Light.Internal.Geometry.MultiplicativeSemigroup (Graphics.Rendering.Plot.Light.Internal.Geometry.DiagMat2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Num.Num a => Graphics.Rendering.Plot.Light.Internal.Geometry.MultiplicativeSemigroup (Graphics.Rendering.Plot.Light.Internal.Geometry.Mat2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Num.Num a => Graphics.Rendering.Plot.Light.Internal.Geometry.VectorSpace (Graphics.Rendering.Plot.Light.Internal.Geometry.V2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Real.Fractional a => Graphics.Rendering.Plot.Light.Internal.Geometry.MatrixGroup (Graphics.Rendering.Plot.Light.Internal.Geometry.DiagMat2 a) (Graphics.Rendering.Plot.Light.Internal.Geometry.V2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Show.Show Graphics.Rendering.Plot.Light.Internal.Geometry.Axis
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Show.Show a => GHC.Show.Show (Graphics.Rendering.Plot.Light.Internal.Geometry.DiagMat2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Show.Show a => GHC.Show.Show (Graphics.Rendering.Plot.Light.Internal.Geometry.Frame a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Show.Show a => GHC.Show.Show (Graphics.Rendering.Plot.Light.Internal.Geometry.Mat2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Show.Show a => GHC.Show.Show (Graphics.Rendering.Plot.Light.Internal.Geometry.MeshGrid a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Show.Show a => GHC.Show.Show (Graphics.Rendering.Plot.Light.Internal.Geometry.Point a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance GHC.Show.Show a => GHC.Show.Show (Graphics.Rendering.Plot.Light.Internal.Geometry.V2 a)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance Graphics.Rendering.Plot.Light.Internal.Geometry.Eps (Graphics.Rendering.Plot.Light.Internal.Geometry.V2 GHC.Types.Double)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance Graphics.Rendering.Plot.Light.Internal.Geometry.Eps (Graphics.Rendering.Plot.Light.Internal.Geometry.V2 GHC.Types.Float)
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance Graphics.Rendering.Plot.Light.Internal.Geometry.Eps GHC.Types.Double
+ Graphics.Rendering.Plot.Light.Internal.Geometry: instance Graphics.Rendering.Plot.Light.Internal.Geometry.Eps GHC.Types.Float
+ Graphics.Rendering.Plot.Light.Internal.Geometry: interpolateBilinear :: Fractional a => Frame a -> Point a -> (Point a -> a) -> a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: labelPoint :: (Point a -> l) -> Point a -> LabeledPoint l a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: mapLabel :: (l1 -> l2) -> LabeledPoint l1 a -> LabeledPoint l2 a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: meshGrid :: (Enum a, RealFrac a) => Frame a -> Int -> Int -> [Point a]
+ Graphics.Rendering.Plot.Light.Internal.Geometry: mkFrame :: Point a -> Point a -> Frame a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: mkFrameOrigin :: Num a => a -> a -> Frame a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: mkLabeledPoint :: Point a -> l -> LabeledPoint l a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: mkPoint :: a -> a -> Point a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: moveLabeledPoint :: (Point a -> Point b) -> LabeledPoint l a -> LabeledPoint l b
+ Graphics.Rendering.Plot.Light.Internal.Geometry: moveLabeledPointBwFrames :: Fractional a => Frame a -> Frame a -> Bool -> Bool -> LabeledPoint l a -> LabeledPoint l a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: moveLabeledPointV2 :: Num a => V2 a -> LabeledPoint l a -> LabeledPoint l a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: movePoint :: Num a => V2 a -> Point a -> Point a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: norm2 :: (Hermitian v, Floating n, n ~ (InnerProduct v)) => v -> n
+ Graphics.Rendering.Plot.Light.Internal.Geometry: normalize2 :: (InnerProduct v ~ Scalar v, Floating (Scalar v), Hermitian v) => v -> v
+ Graphics.Rendering.Plot.Light.Internal.Geometry: oneOne :: Num a => Point a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: origin :: Num a => Point a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: otherAxis :: Axis -> Axis
+ Graphics.Rendering.Plot.Light.Internal.Geometry: pointFromV2 :: V2 a -> Point a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: pointRange :: (Fractional a, Integral n) => n -> Point a -> Point a -> [Point a]
+ Graphics.Rendering.Plot.Light.Internal.Geometry: setPointX :: a -> Point a -> Point a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: setPointY :: a -> Point a -> Point a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: subdivSegment :: (Real a, Enum b, RealFrac b) => a -> a -> Int -> [b]
+ Graphics.Rendering.Plot.Light.Internal.Geometry: type family InnerProduct v :: *;
+ Graphics.Rendering.Plot.Light.Internal.Geometry: v2fromEndpoints :: Num a => Point a -> Point a -> V2 a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: v2fromPoint :: Num a => Point a -> V2 a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: width :: Num a => Frame a -> a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: xmax :: Frame a -> a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: xmin :: Frame a -> a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: ymax :: Frame a -> a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: ymin :: Frame a -> a
+ Graphics.Rendering.Plot.Light.Internal.Geometry: zero :: AdditiveGroup v => v
+ Graphics.Rendering.Plot.Light.Internal.Geometry: }
Files
- plot-light.cabal +4/−4
- src/Graphics/Rendering/Plot/Light.hs +6/−21
- src/Graphics/Rendering/Plot/Light/Internal.hs +58/−16
- src/Graphics/Rendering/Plot/Light/Internal/Geometry.hs +35/−12
- test/LibSpec.hs +1/−0
plot-light.cabal view
@@ -1,5 +1,5 @@ name: plot-light-version: 0.3.1+version: 0.3.2 synopsis: A lightweight plotting library, exporting to SVG description: This library provides drawing and plotting datastructures and functions; it is aimed in particular at scientific visualization, but it also exposes its plotting primitives and a small but general purpose 2D geometry library. @@ -16,7 +16,7 @@ extra-doc-files: doc/fig/heatmap.png doc/fig/scatter.png cabal-version: >=1.18-tested-with: GHC == 8.0.2, GHC == 8.4.1+tested-with: GHC == 8.0.2, GHC == 8.2.2 library@@ -26,6 +26,7 @@ exposed-modules: Graphics.Rendering.Plot.Light Data.TimeSeries Graphics.Rendering.Plot.Light.PlotTypes+ Graphics.Rendering.Plot.Light.Internal.Geometry other-modules: Graphics.Rendering.Plot.Light.Internal Graphics.Rendering.Plot.Light.Internal.Layout Graphics.Rendering.Plot.Light.PlotTypes.Heatmap@@ -33,7 +34,6 @@ Graphics.Rendering.Plot.Light.PlotTypes.Histogram Graphics.Rendering.Plot.Light.PlotTypes.TimeSeries Graphics.Rendering.Plot.Light.PlotTypes.TimeSeries.Candlestick- Graphics.Rendering.Plot.Light.Internal.Geometry Graphics.Rendering.Plot.Light.Internal.Utils Data.Parsers build-depends: base >= 4.7 && < 5@@ -44,7 +44,7 @@ , scientific , text , time- , data-default+ , data-default-class -- -- * DEBUG -- , hspec -- , QuickCheck
src/Graphics/Rendering/Plot/Light.hs view
@@ -139,33 +139,18 @@ axes, toPlot, FigureData(..), -- ** Element attributes LineStroke_(..), StrokeLineJoin_(..), TextAnchor_(..), LegendPosition_(..),+ -- ** Operations on frames+ frameFromPoints, frameFromFigData, mkFrame, mkFrameOrigin, width, height, figFWidth, figFHeight, -- ** Colour utilities blendTwo, palette, pickColour, -- ** SVG utilities- svgHeader, translateSvg,+ svgHeader, translateSvg, toSvgFrame, toSvgFrameLP, -- * Types Frame(..), Point(..), LabeledPoint(..), labelPoint, mapLabel, Axis(..),- -- * Geometry- -- ** Vectors- V2(..),- -- ** Matrices- Mat2(..), DiagMat2(..), diagMat2,- -- ** Primitive elements- origin, e1, e2,- -- ** Vector norm operations - norm2, normalize2,- -- ** Vector construction- v2fromEndpoints, v2fromPoint,- -- ** Operations on points- movePoint, moveLabeledPointV2, moveLabeledPointBwFrames, (-.), toSvgFrame, toSvgFrameLP, pointRange,- -- ** Operations on vectors- frameToFrame, - -- ** Operations on frames- frameFromPoints, frameFromFigData, mkFrame, mkFrameOrigin, width, height, figFWidth, figFHeight,- -- ** Typeclasses- AdditiveGroup(..), VectorSpace(..), Hermitian(..), LinearMap(..), MultiplicativeSemigroup(..), MatrixGroup(..), Eps(..), -- ** Helpers- meshGrid, toFloat, wholeDecimal+ meshGrid,+ -- *** Misc.+ toFloat, wholeDecimal ) where -- import qualified Data.Text as T
src/Graphics/Rendering/Plot/Light/Internal.hs view
@@ -1,5 +1,7 @@-{-# LANGUAGE OverloadedStrings, DeriveFunctor #-}-module Graphics.Rendering.Plot.Light.Internal (FigureData(..), Frame(..), mkFrame, mkFrameOrigin, frameToFrame, frameToFrameValue, frameFromPoints, frameFromFigData, xmin,xmax,ymin,ymax, width, height, figFWidth, figFHeight, Point(..), mkPoint, LabeledPoint(..), mkLabeledPoint, labelPoint, mapLabel, Axis(..), axes, meshGrid, subdivSegment, svgHeader, rect, rectCentered, squareCentered, circle, line, tick, ticks, axis, toPlot, text, pixel, pixel', pickColour, colourBar, legendBar, plusGlyph, crossGlyph, polyline, filledPolyline, filledBand, candlestick, strokeLineJoin, LineStroke_(..), StrokeLineJoin_(..), TextAnchor_(..), LegendPosition_(..), V2(..), Mat2(..), DiagMat2(..), diagMat2, AdditiveGroup(..), VectorSpace(..), Hermitian(..), LinearMap(..), MultiplicativeSemigroup(..), MatrixGroup(..), Eps(..), norm2, normalize2, v2fromEndpoints, v2fromPoint, origin, (-.), pointRange, movePoint, moveLabeledPointV2, moveLabeledPointBwFrames, translateSvg, toSvgFrame, toSvgFrameLP, e1, e2, toFloat, wholeDecimal, blendTwo, palette) where+{-# LANGUAGE OverloadedStrings, DeriveFunctor, DeriveGeneric #-}+module Graphics.Rendering.Plot.Light.Internal+ (FigureData(..), Frame(..), mkFrame, mkFrameOrigin, frameToFrame, frameToFrameValue, frameFromPoints, frameFromFigData, xmin,xmax,ymin,ymax, width, height, figFWidth, figFHeight, Point(..), mkPoint, LabeledPoint(..), mkLabeledPoint, labelPoint, mapLabel, Axis(..), axes, meshGrid, subdivSegment, svgHeader, rect, rectCentered, squareCentered, circle, line, tick, ticks, axis, toPlot, text, pixel, pixel', pickColour, colourBar, legendBar, plusGlyph, crossGlyph, polyline, filledPolyline, filledBand, candlestick, strokeLineJoin, LineStroke_(..), StrokeLineJoin_(..), TextAnchor_(..), LegendPosition_(..), V2(..), Mat2(..), DiagMat2(..), diagMat2, AdditiveGroup(..), VectorSpace(..), Hermitian(..), LinearMap(..), MultiplicativeSemigroup(..), MatrixGroup(..), Eps(..), norm2, normalize2, v2fromEndpoints, v2fromPoint, origin, (-.), pointRange, movePoint, moveLabeledPointV2, moveLabeledPointBwFrames, translateSvg, toSvgFrame, toSvgFrameLP, e1, e2, toFloat, wholeDecimal, blendTwo, palette, interpolateBilinear)+ where import Data.Monoid ((<>)) import qualified Data.Foldable as F (toList)@@ -25,7 +27,9 @@ import qualified Data.Colour.SRGB as C import GHC.Real+import GHC.Generics import Data.Fixed+import Data.Default.Class import Graphics.Rendering.Plot.Light.Internal.Geometry import Graphics.Rendering.Plot.Light.Internal.Utils@@ -50,9 +54,10 @@ -- , figAxisStrokeWidth :: a -- | Tick label font size , figLabelFontSize :: Int- } deriving (Eq, Show, Functor)-+ } deriving (Eq, Show, Functor, Generic) +instance (Default a, Fractional a) => Default (FigureData a) where+ def = FigureData 400 300 0.1 0.9 0.1 0.9 10 @@ -105,20 +110,48 @@ y0c = y0 - (hei / 2) -+-- | A square, defined by its center coordinates and side length squareCentered :: (Show a, RealFrac a) =>- a- -> a- -> Maybe (C.Colour Double)- -> Maybe (C.Colour Double)- -> Point a+ a -- ^ Side length+ -> a -- ^ Stroke width+ -> Maybe (C.Colour Double) -- ^ Stroke colour+ -> Maybe (C.Colour Double) -- ^ Fill colour+ -> Point a -- ^ Center coordinates -> Svg squareCentered w = rectCentered w w +newtype Col = Col { unCol :: C.Colour Double} deriving (Eq, Show, Generic)+instance Default Col where+ def = Col C.blue +data LineOptions a = LineOptions {+ loStrokeWidth :: a -- ^ Stroke width + , loStrokeType :: LineStroke_ a -- ^ Stroke type+ , loColour :: Col -- ^ Stroke colour+ } deriving (Eq, Show, Generic) +-- | Line options "picker". Creates an unbounded stream of LineOptions, may be useful when plotting multiple timeseries (essentially imitating the Matlab behaviour)+lineOptionCycle :: Fractional a => a -> [LineOptions a]+lineOptionCycle lw =+ let+ strTys =+ replicate 5 Continuous <>+ replicate 5 (Dashed [0.2, 0.5]) <>+ replicate 5 (Dashed [0.5, 0.2]) + cols = Col <$> [C.blue, C.green, C.red, C.black, C.purple]+ nc = length cols+ in+ LineOptions <$>+ repeat lw <*>+ strTys <*>+ cols++instance (Default a, Num a) => Default (LineOptions a) where+ def = LineOptions 2 def def++ -- | Line segment between two `Point`s -- -- > > putStrLn $ renderSvg $ line (Point 0 0) (Point 1 1) 0.1 Continuous C.blueviolet@@ -133,15 +166,21 @@ -> LineStroke_ a -- ^ Stroke type -> C.Colour Double -- ^ Stroke colour -> Svg-line (Point x1 y1) (Point x2 y2) sw Continuous col = S.line ! SA.x1 (vd x1) ! SA.y1 (vd y1) ! SA.x2 (vd x2) ! SA.y2 (vd y2) ! SA.stroke (colourAttr col ) ! SA.strokeWidth (vd sw)-line (Point x1 y1) (Point x2 y2) sw (Dashed d) col = S.line ! SA.x1 (vd x1) ! SA.y1 (vd y1) ! SA.x2 (vd x2) ! SA.y2 (vd y2) ! SA.stroke (colourAttr col ) ! SA.strokeWidth (vd sw) ! strokeDashArray d+line (Point x1 y1) (Point x2 y2) sw lstr col =+ let+ svg0 = S.line ! SA.x1 (vd x1) ! SA.y1 (vd y1) ! SA.x2 (vd x2) ! SA.y2 (vd y2) ! SA.stroke (colourAttr col) ! SA.strokeWidth (vd sw)+ in case lstr of Continuous -> svg0+ Dashed d -> svg0 ! strokeDashArray d + strokeDashArray :: Real a => [a] -> S.Attribute strokeDashArray sz = SA.strokeDasharray (S.toValue str) where str = intercalate ", " $ map (show . real) sz -- | Specify a continuous or dashed stroke-data LineStroke_ a = Continuous | Dashed [a] deriving (Eq, Show)+data LineStroke_ a = Continuous | Dashed [a] deriving (Eq, Show, Generic)+instance Default (LineStroke_ a) where+ def = Continuous @@ -194,7 +233,7 @@ -> Int -- ^ Font size -> a -- ^ Label angle -> TextAnchor_ - -> (t -> T.Text) -- ^ Label rendering+ -> (t -> T.Text) -- ^ Label rendering function -> V2 a -- ^ Label shift -> LabeledPoint t a -> Svg@@ -396,8 +435,11 @@ -> C.Colour Double -- ^ Stroke colour -> t (Point a) -- ^ Data -> Svg-polyline sw Continuous slj col lis = S.polyline ! SA.points (S.toValue $ unwords $ map show $ F.toList lis) ! SA.fill none ! SA.stroke (colourAttr col ) ! SA.strokeWidth (vd sw) ! strokeLineJoin slj-polyline sw (Dashed d) slj col lis = S.polyline ! SA.points (S.toValue $ unwords $ map show $ F.toList lis) ! SA.fill none ! SA.stroke (colourAttr col ) ! SA.strokeWidth (vd sw) ! strokeLineJoin slj ! strokeDashArray d+polyline sw strTy slj col lis =+ let+ svg0 = S.polyline ! SA.points (S.toValue $ unwords $ map show $ F.toList lis) ! SA.fill none ! SA.stroke (colourAttr col ) ! SA.strokeWidth (vd sw) ! strokeLineJoin slj+ in case strTy of Continuous -> svg0+ Dashed d -> svg0 ! strokeDashArray d none :: S.AttributeValue none = S.toValue ("none" :: String)
src/Graphics/Rendering/Plot/Light/Internal/Geometry.hs view
@@ -3,12 +3,42 @@ This module provides functionality for working with affine transformations (i.e. in the unit square) -}-module Graphics.Rendering.Plot.Light.Internal.Geometry where+module Graphics.Rendering.Plot.Light.Internal.Geometry+ (+ -- * Geometry+ -- ** Point+ Point(..), mkPoint, setPointX, setPointY,+ -- ** LabeledPoint+ LabeledPoint(..), mkLabeledPoint, labelPoint, moveLabeledPoint, mapLabel,+ -- ** Frame+ Frame(..), mkFrame, frameFromPoints, mkFrameOrigin, height, width, xmin, xmax, ymin, ymax, + -- ** Axis+ Axis(..), otherAxis,+ -- ** Vectors+ V2(..), pointFromV2,+ -- ** Matrices+ Mat2(..), DiagMat2(..), diagMat2,+ -- ** Primitive elements+ origin, oneOne, e1, e2,+ -- ** Vector norm operations + norm2, normalize2,+ -- ** Vector construction+ v2fromEndpoints, v2fromPoint,+ -- ** Operations on points+ movePoint, moveLabeledPointV2, moveLabeledPointBwFrames, (-.), pointRange,+ -- ** Operations on vectors+ frameToFrame, frameToFrameValue,+ -- ** Typeclasses+ AdditiveGroup(..), VectorSpace(..), Hermitian(..), LinearMap(..), MultiplicativeSemigroup(..), MatrixGroup(..), Eps(..),+ -- ** Utilities+ meshGrid, subdivSegment, interpolateBilinear+ )+where import Data.Monoid ((<>)) import GHC.Generics-import Data.Default+import Data.Default.Class @@ -91,7 +121,8 @@ _fpmax :: Point a } deriving (Eq, Show, Generic) -instance Default a => Default (Frame a) where+instance (Default a, Num a) => Default (Frame a) where+ def = unitFrame -- | The semigroup operation (`mappend`) applied on two `Frames` results in a new `Frame` that bounds both. instance (Ord a, Num a) => Monoid (Frame a) where@@ -370,17 +401,9 @@ data MeshGrid a = MeshGrid (Frame a) Int Int deriving (Eq, Show, Generic) -instance Default a => Default (MeshGrid a) where+instance (Default a, Num a) => Default (MeshGrid a) where ---- subdivSegment--- :: (Enum a, RealFrac a) => a -> a -> Int -> [a]--- subdivSegment x1 x2 n = [xmin, xmin + dx ..] where--- dx = fromRational . toRational $ l / fromIntegral n--- xmin = min x1 x2--- xmax = max x1 x2--- l = xmax - xmin subdivSegment :: (Real a, Enum b, RealFrac b) => a -> a -> Int -> [b] subdivSegment x1 x2 n = f <$> [0, 1 ..] where
test/LibSpec.hs view
@@ -6,6 +6,7 @@ import Test.QuickCheck import Graphics.Rendering.Plot.Light+import Graphics.Rendering.Plot.Light.Internal.Geometry import Data.TimeSeries main :: IO ()