plot 0.1.1.3 → 0.1.1.4
raw patch · 7 files changed
+44/−42 lines, 7 filesdep −base-unicode-symbols
Dependencies removed: base-unicode-symbols
Files
- CHANGES +3/−0
- lib/Graphics/Rendering/Plot/Figure/Plot.hs +6/−7
- lib/Graphics/Rendering/Plot/Figure/Simple.hs +2/−3
- lib/Graphics/Rendering/Plot/Render/Plot/Axis.hs +10/−11
- lib/Graphics/Rendering/Plot/Render/Plot/Data.hs +13/−12
- lib/Graphics/Rendering/Plot/Types.hs +2/−3
- plot.cabal +8/−6
CHANGES view
@@ -12,3 +12,6 @@ 0.1.1.3: * fixed bug (lack of stroke) with datasets larger than window * hollow points fill with white++0.1.1.4:+ * remove Unicode dependency
lib/Graphics/Rendering/Plot/Figure/Plot.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE UnicodeSyntax #-} ----------------------------------------------------------------------------- -- | -- Module : Graphics.Rendering.Plot.Figure.Plot@@ -67,8 +66,8 @@ ----------------------------------------------------------------------------- -import Data.Eq.Unicode-import Data.Bool.Unicode+--import Data.Eq.Unicode+--import Data.Bool.Unicode --import Data.Ord.Unicode --import Data.Packed.Vector@@ -109,10 +108,10 @@ ----------------------------------------------------------------------------- -- | set the axis range-setRange :: AxisType -> AxisSide -> Scale → Double -> Double -> Plot ()+setRange :: AxisType -> AxisSide -> Scale -> Double -> Double -> Plot () setRange XAxis sd sc min max = modify $ \s -> s { _ranges = setXRanges' (_ranges s) } where setXRanges' r- | sc ≡ Log ∧ min <= 0 = error "non-positive logarithmic range"+ | sc == Log && min <= 0 = error "non-positive logarithmic range" | otherwise = setXRanges sd r setXRanges Lower (Ranges (Left _) yr) = Ranges (Left (Range sc min max)) yr setXRanges Lower (Ranges (Right (_,xr)) yr) = Ranges (Right ((Range sc min max,xr))) yr@@ -120,7 +119,7 @@ setXRanges Upper (Ranges (Right (_,xr)) yr) = Ranges (Right (Range sc min max,xr)) yr setRange YAxis sd sc min max = modify $ \s -> s { _ranges = setYRanges' (_ranges s) } where setYRanges' r- | sc ≡ Log ∧ min <= 0 = error "non-positive logarithmic range"+ | sc == Log && min <= 0 = error "non-positive logarithmic range" | otherwise = setYRanges sd r setYRanges Lower (Ranges xr (Left _)) = Ranges xr (Left (Range sc min max)) setYRanges Lower (Ranges xr (Right (_,yr))) = Ranges xr (Right ((Range sc min max,yr)))@@ -128,7 +127,7 @@ setYRanges Upper (Ranges xr (Right (_,yr))) = Ranges xr (Right ((Range sc min max,yr))) -- | set the axis ranges to values based on dataset-setRangeFromData :: AxisType -> AxisSide -> Scale → Plot ()+setRangeFromData :: AxisType -> AxisSide -> Scale -> Plot () setRangeFromData ax sd sc = do ds <- gets _data let ((xmin,xmax),(ymin,ymax)) = calculateRanges ds
lib/Graphics/Rendering/Plot/Figure/Simple.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE UnicodeSyntax #-} ----------------------------------------------------------------------------- -- | -- Module : Graphics.Rendering.Plot.Figure@@ -118,11 +117,11 @@ withAxis YAxis (Side Lower) $ setGridlines Major b -- | set the x range-xrange :: Simple m => Scale -> Double -> Double → m ()+xrange :: Simple m => Scale -> Double -> Double -> m () xrange s l h = simple $ setRange XAxis Lower s l h -- | set the y range-yrange :: Simple m => Scale -> Double -> Double → m ()+yrange :: Simple m => Scale -> Double -> Double -> m () yrange s l h = simple $ setRange YAxis Lower s l h -- | set the x range from data
lib/Graphics/Rendering/Plot/Render/Plot/Axis.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE UnicodeSyntax #-} ----------------------------------------------------------------------------- -- | -- Module : Graphics.Rendering.Plot.Render.Plot.Axis@@ -20,9 +19,9 @@ ----------------------------------------------------------------------------- -import Data.Eq.Unicode-import Data.Function.Unicode-import Prelude.Unicode+--import Data.Eq.Unicode+--import Data.Function.Unicode+--import Prelude.Unicode import Data.Either @@ -282,11 +281,11 @@ C.lineTo (x+w+0.5) (y+h) C.stroke -tickPosition :: Scale → Double -> Double -> Int -> [(Double,Double)]-tickPosition sc min max n = let pos = map (\x -> min + (max-min)*(x)/(fromIntegral (n-1))) (take n [(0 ∷ Double)..])- val = if sc ≡ Log- then map (\x → logBase 10 min + (x÷(fromIntegral (n-1))) ⋅ (logBase 10 max - logBase 10 min))- (take n [(0 ∷ Double)..])+tickPosition :: Scale -> Double -> Double -> Int -> [(Double,Double)]+tickPosition sc min max n = let pos = map (\x -> min + (max-min)*(x)/(fromIntegral (n-1))) (take n [(0 :: Double)..])+ val = if sc == Log+ then map (\x -> logBase 10 min + (x/(fromIntegral (n-1))) * (logBase 10 max - logBase 10 min))+ (take n [(0 :: Double)..]) else pos in zip pos val {-@@ -354,7 +353,7 @@ --map ((/) 2 . (+) 1 . (/) (fromIntegral tmaj) . fromIntegral . (mod tmaj)) (take (tmin+1) [0..]) renderAxisTick :: P.PangoContext -> TextOptions - -> Double -> Double -> Double -> Double -> Scale → Double -> Double+ -> Double -> Double -> Double -> Double -> Scale -> Double -> Double -> AxisType -> AxisPosn -> TickFormat -> Tick -> GridLines -> (Double,Double,Double) -> C.Render () renderAxisTick pc to x y w h sc min max xa sd tf t gl (p,l,v) = do@@ -407,7 +406,7 @@ (Side _) -> True (Value _) -> False when (t == Major && majlab) $ do- let s = if sc ≡ Log then formatTick "10e%.1g" v else formatTick tf v+ let s = if sc == Log then formatTick "10e%.1g" v else formatTick tf v lo <- pango $ P.layoutText pc s setTextOptions (scaleFontSize tickLabelScale to) lo case xa of
lib/Graphics/Rendering/Plot/Render/Plot/Data.hs view
@@ -1,5 +1,6 @@-{-# LANGUAGE UnicodeSyntax #-} {-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE UnicodeSyntax #-}+ ----------------------------------------------------------------------------- -- | -- Module : Graphics.Rendering.Plot.Render.Plot.Data@@ -22,7 +23,7 @@ ----------------------------------------------------------------------------- import Data.List(partition)-import Prelude.Unicode+--import Prelude.Unicode import Foreign.Storable import Foreign.Ptr@@ -129,11 +130,11 @@ let (los,ups) = partition (\(_,DecSeries o _) -> isLower o) aos (BoundingBox x y w h) <- get let (xsc,xmin',xmax') = getRanges XAxis Lower r- let (xmin,xmax) = if xsc ≡ Log then (logBase 10 xmin',logBase 10 xmax') else (xmin',xmax')+ let (xmin,xmax) = if xsc == Log then (logBase 10 xmin',logBase 10 xmax') else (xmin',xmax') let xscale = w/(xmax-xmin) cairo $ C.save let (yscl,yminl',ymaxl') = getRanges YAxis Lower r- let (yminl,ymaxl) = if yscl ≡ Log then (logBase 10 yminl',logBase 10 ymaxl') else (yminl',ymaxl')+ let (yminl,ymaxl) = if yscl == Log then (logBase 10 yminl',logBase 10 ymaxl') else (yminl',ymaxl') let yscalel = h/(ymaxl-yminl) -- transform to data coordinates cairo $ do @@ -147,7 +148,7 @@ (do cairo $ C.save let (yscu,yminu',ymaxu') = getRanges YAxis Upper r- let (yminu,ymaxu) = if yscu ≡ Log then (logBase 10 yminu',logBase 10 ymaxu') else (yminu',ymaxu')+ let (yminu,ymaxu) = if yscu == Log then (logBase 10 yminu',logBase 10 ymaxu') else (yminu',ymaxu') let yscaleu = h/(ymaxu-yminu) -- transform to data coordinates cairo $ do @@ -188,10 +189,10 @@ AbsPoints t' -> t' return $ Right [((t,o'),(t,(l,h)))] let dat = case dat' of- Left dat'' → map (\(a,b) → Left (if xsc ≡ Log then (logBase 10 a) else a+ Left dat'' → map (\(a,b) -> Left (if xsc == Log then (logBase 10 a) else a ,if ysc == Log then (logBase 10 b) else b)) dat''- Right dat''' → map (\((a,(bl,bu)),(c,(dl,du))) → let (a',c') = if xsc ≡ Log then (logBase 10 a,logBase 10 c) else (a,c)- (bl',bu',dl',du') = if ysc ≡ Log then (logBase 10 bl,logBase 10 bu,logBase 10 dl,logBase 10 du) else (bl,bu,dl,du) + Right dat''' → map (\((a,(bl,bu)),(c,(dl,du))) → let (a',c') = if xsc == Log then (logBase 10 a,logBase 10 c) else (a,c)+ (bl',bu',dl',du') = if ysc == Log then (logBase 10 bl,logBase 10 bu,logBase 10 dl,logBase 10 du) else (bl,bu,dl,du) in Right ((a',(bl',bu')),(c',(dl',du')))) dat''' case d of (DecLine lt) -> do@@ -476,10 +477,10 @@ C.lineTo x yu if whiskers then do- C.moveTo (x-bw÷2) yu- C.lineTo (x+bw÷2) yu- C.moveTo (x-bw÷2) yl- C.lineTo (x+bw÷2) yl+ C.moveTo (x-bw/2) yu+ C.lineTo (x+bw/2) yu+ C.moveTo (x-bw/2) yl+ C.lineTo (x+bw/2) yl else return () C.stroke
lib/Graphics/Rendering/Plot/Types.hs view
@@ -3,7 +3,6 @@ {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE UnicodeSyntax #-} ----------------------------------------------------------------------------- -- | -- Module : Graphics.Rendering.Plot.Types@@ -143,7 +142,7 @@ data Scale = Linear | Log deriving(Eq) -data Range = Range { _range_scale ∷ Scale, _range_min :: Double, _range_max :: Double }+data Range = Range { _range_scale :: Scale, _range_min :: Double, _range_max :: Double } data Ranges = Ranges (Either Range (Range,Range)) (Either Range (Range,Range)) @@ -264,7 +263,7 @@ getOrdData (Error o _) = o getOrdData (MinMax (o,_) _) = o -getMinMaxData ∷ OrdSeries → Either MinMaxSeries (MinMaxSeries,(ErrorSeries,ErrorSeries))+getMinMaxData :: OrdSeries -> Either MinMaxSeries (MinMaxSeries,(ErrorSeries,ErrorSeries)) getMinMaxData (MinMax o Nothing) = Left o getMinMaxData (MinMax o (Just e)) = Right (o,e)
plot.cabal view
@@ -1,5 +1,5 @@ Name: plot-Version: 0.1.1.3+Version: 0.1.1.4 License: BSD3 License-file: LICENSE Copyright: (c) A.V.H. McPhail 2010@@ -33,7 +33,11 @@ <http://code.haskell.org/plot/examples/perturbed-sine.png> . Changes in plot 0.1.1+ . * added candle and whisker plots+ .+ Changes in plot 0.2+ . Category: Graphics Tested-with: GHC==6.12.1@@ -47,7 +51,6 @@ library Build-Depends: base >= 4 && < 5,- base-unicode-symbols, mtl, array, MaybeT, pango >= 0.11.2 && < 0.12, cairo >= 0.11.1 && < 0.12,@@ -60,7 +63,6 @@ FlexibleInstances FlexibleContexts UndecidableInstances- UnicodeSyntax hs-source-dirs: lib Exposed-Modules: Graphics.Rendering.Plot@@ -91,6 +93,6 @@ ghc-prof-options: -auto - source-repository head- type: darcs- location: darcs get http://code.haskell.org/plot+source-repository head+ type: darcs+ location: http://code.haskell.org/plot