packages feed

plot 0.1.2 → 0.1.2.1

raw patch · 11 files changed

+94/−36 lines, 11 files

Files

CHANGES view
@@ -18,3 +18,10 @@  0.1.2: 		* improve axis line joins+		* annotations++0.1.2.1:+		* save/restore cairo annotation+		* add setDataset documentation+		* improve Dashes+		* formattable grid lines
lib/Graphics/Rendering/Plot/Defaults.hs view
@@ -70,6 +70,9 @@ defaultLineType :: LineType defaultLineType = ColourLine black +defaultGridLine :: LineType+defaultGridLine = ColourLine grey + -----------------------------------------------------------------------------  defaultBarWidth :: Double@@ -157,10 +160,10 @@ tickLabelScale = 0.75  defaultMinorTicks :: Ticks-defaultMinorTicks = Ticks False (Left 41)+defaultMinorTicks = Ticks NoLine (Left 41)  defaultMajorTicks :: Ticks-defaultMajorTicks = Ticks False (Left 5)+defaultMajorTicks = Ticks NoLine (Left 5)  defaultTickFormat :: TickFormat defaultTickFormat = ""
lib/Graphics/Rendering/Plot/Figure/Plot.hs view
@@ -71,6 +71,7 @@                                            , AX.setTickLabelFormat                                            , AX.withAxisLabel                                            , AX.withAxisLine+                                           , AX.withGridLine                                            ) where  -----------------------------------------------------------------------------@@ -202,7 +203,30 @@ withData :: D.Data () -> Plot () withData = dataInPlot --- | set the data series of the subplot+{- | set the data series of the subplot++   The data series are either 'DecoratedSeries' or plain data series.+   A plain data series must carry a 'SeriesType'.++  A dataset may or may not have an abscissa series, and if so, it is paired+  with either a list of ordinate series or a single ordinate series.++  The abscissa series (if present) is of type 'Vector Double'.++  An ordinate series be a function (@Double -> Double@) or a series of points,+  a 'Vector Double' with optional error series, y axis preference, and labels.++  To specify decoration options for an ordinate series, use the appropriate function, such+  as 'linespoints', with the ordinate series and decoration formatting ('LineFormat',+  'PointFormat', and 'BarFormat') as arguments.++> setDataset (ts,[linespoints (xs,(le,ue),Upper,"data") (([Dash,Dash],3,blue),(Diamond,green))])++  has abscissa @ts@ paired with a list of ordinate series, the single element of which is a+  'DecoratedSeries', @linespoints@ where the ordinate is @xs@ with error series @le@ and @ue@,+  to be graphed against the upper y-range with label \"data\".  The line element is formatted+  to be dashed, of width 3, and blue and the point element is to be a green diamond.+-} setDataset :: D.Dataset a => a -> Plot () setDataset d = withData $ D.setDataSeries d 
lib/Graphics/Rendering/Plot/Figure/Plot/Annotation.hs view
@@ -13,7 +13,8 @@ -----------------------------------------------------------------------------  module Graphics.Rendering.Plot.Figure.Plot.Annotation (-                                                       clearAnnotations+                                                       Annote+                                                      , clearAnnotations                                                       , arrow                                                       , oval                                                       , rect
lib/Graphics/Rendering/Plot/Figure/Plot/Axis.hs view
@@ -13,15 +13,16 @@ -----------------------------------------------------------------------------  module Graphics.Rendering.Plot.Figure.Plot.Axis (-                                            Axis-                                           , AxisType(..),AxisSide(..),AxisPosn(..)-                                           , Tick(..), TickValues, GridLines-                                           , setTicks-                                           , setGridlines-                                           , setTickLabelFormat-                                           , withAxisLabel-                                           , withAxisLine-                                    ) where+                                                 Axis+                                                , AxisType(..),AxisSide(..),AxisPosn(..)+                                                , Tick(..), TickValues, GridLines+                                                , setTicks+                                                , setGridlines+                                                , setTickLabelFormat+                                                , withAxisLabel+                                                , withAxisLine+                                                , withGridLine+                                                ) where  ----------------------------------------------------------------------------- @@ -29,6 +30,7 @@ import Control.Monad.Reader  import Graphics.Rendering.Plot.Types+import Graphics.Rendering.Plot.Defaults  ----------------------------------------------------------------------------- @@ -57,6 +59,22 @@                  let lt = execLine m lo l                  modify $ \s -> s { _line_type = lt } +-- | format the grid lines+withGridLine :: Tick -> Line () -> Axis ()+withGridLine t m = do+                 lo <- asks _lineoptions+                 (lt',v) <- case t of+                        Minor -> do+                               (Ticks lt'' v') <- gets _minor_ticks+                               return (lt'',v')+                        Major -> do+                               (Ticks lt'' v') <- gets _major_ticks+                               return (lt'',v')+                 let lt = execLine m lo lt'+                 case t of+                   Minor -> modify $ \s -> s { _minor_ticks = Ticks lt v }+                   Major -> modify $ \s -> s { _major_ticks = Ticks lt v }+ -- | format the axis ticks setTicks :: Tick -> TickValues -> Axis () setTicks Minor ts = modify $ \s -> changeMinorTicks (setTickValues ts) s@@ -64,8 +82,8 @@  -- | should gridlines be displayed? setGridlines :: Tick -> GridLines -> Axis ()-setGridlines Minor gl = modify $ \s -> changeMinorTicks (setTickGridlines gl) s-setGridlines Major gl = modify $ \s -> changeMajorTicks (setTickGridlines gl) s+setGridlines Minor gl = modify $ \s -> changeMinorTicks (setTickGridlines (if gl then defaultGridLine else NoLine)) s+setGridlines Major gl = modify $ \s -> changeMajorTicks (setTickGridlines (if gl then defaultGridLine else NoLine)) s  -- | printf format that takes one argument, the tick value setTickLabelFormat :: String -> Axis ()
lib/Graphics/Rendering/Plot/Render/Plot/Annotation.hs view
@@ -25,17 +25,17 @@ import Control.Monad.State  import Graphics.Rendering.Plot.Types-import Graphics.Rendering.Plot.Defaults+--import Graphics.Rendering.Plot.Defaults -import Graphics.Rendering.Plot.Figure.Text+--import Graphics.Rendering.Plot.Figure.Text  import Graphics.Rendering.Plot.Render.Types import Graphics.Rendering.Plot.Render.Text import Graphics.Rendering.Plot.Render.Plot.Glyph import Graphics.Rendering.Plot.Render.Plot.Format -import Prelude hiding(min,max)-import qualified Prelude(max)+--import Prelude hiding(min,max)+--import qualified Prelude(max)  ----------------------------------------------------------------------------- @@ -131,6 +131,9 @@   return () renderAnnotation _   _   (AnnCairo r) = do   (BoundingBox x y w h) <- get-  cairo $ r x y w h+  cairo $ do+    C.save+    r x y w h+    C.restore  -----------------------------------------------------------------------------
lib/Graphics/Rendering/Plot/Render/Plot/Axis.hs view
@@ -381,7 +381,7 @@  renderAxisTick :: P.PangoContext -> TextOptions                 -> Double -> Double -> Double -> Double -> Scale -> Double -> Double-               -> AxisType -> AxisPosn -> TickFormat -> Tick -> GridLines+               -> AxisType -> AxisPosn -> TickFormat -> Tick -> LineType                -> (Double,Double,Double) -> C.Render () renderAxisTick pc to x y w h sc min max xa sd tf t gl (p,l,v) = do        let tl' = case t of@@ -406,7 +406,7 @@        moveTo x1 y1        lineTo x2 y2        C.stroke-       when gl (do+       when (gl /= NoLine)  (do                 let (x3,y3,x4,y4) = case xa of                                    XAxis -> case sd of                                                     (Side Lower) -> let xt x' = x + (x'-min)*w/(max-min)@@ -423,10 +423,7 @@                                                     (Value _)    -> let yt y' = (y + h) - (y'-min)*h/(max-min)                                                                     in (x,yt p,x+w,yt p)                 C.save-                lw <- C.getLineWidth-                C.setLineWidth (lw/2)-                C.setDash [4,4] 0-                C.setSourceRGBA 0 0 0 0.5+                setLineStyle gl                              moveTo x3 y3                 lineTo x4 y4                 C.stroke
lib/Graphics/Rendering/Plot/Render/Plot/Data.hs view
@@ -25,8 +25,8 @@ import Data.List(partition) --import Prelude.Unicode -import Foreign.Storable -import Foreign.Ptr+--import Foreign.Storable +--import Foreign.Ptr  --import Data.Packed.Vector --import Data.Packed.Matrix@@ -51,7 +51,7 @@ import Graphics.Rendering.Plot.Render.Types import Graphics.Rendering.Plot.Render.Plot.Format import Graphics.Rendering.Plot.Render.Plot.Glyph-import Graphics.Rendering.Plot.Render.Plot.Annotation+--import Graphics.Rendering.Plot.Render.Plot.Annotation  import Prelude hiding(min,max,abs) import qualified Prelude@@ -309,9 +309,9 @@                                          case s of                                                 Nothing -> C.moveTo (t @> xmin_ix) ((fst $ y) @> xmin_ix)                                                 Just s' -> s'-                                         _ <- runMaybeT $ mapVectorWithIndexM_ (\i t -> do+                                         _ <- runMaybeT $ mapVectorWithIndexM_ (\i t' -> do                                             when (i >= xmin_ix && i `mod` diff == 0)-                                                     (renderMinMaxSample i xmax_ix t f e y)+                                                     (renderMinMaxSample i xmax_ix t' f e y)                                             return ()) t                                          return () 
lib/Graphics/Rendering/Plot/Render/Types.hs view
@@ -128,7 +128,7 @@ setDashes :: [Dash] -> C.Render () setDashes [] = C.setDash [] 0 setDashes xs = do-               let xs' = concat $ map (\d -> case d of { Dot -> [1,1] ; Dash -> [2,1] }) xs+               let xs' = map (\d -> case d of { Dot -> 1 ; Dash -> 3 }) xs                C.setDash xs' 0                       -----------------------------------------------------------------------------
lib/Graphics/Rendering/Plot/Types.hs view
@@ -88,17 +88,19 @@  ----------------------------------------------------------------------------- -data Dash = Dot | Dash+data Dash = Dot | Dash deriving(Eq) type DashStyle = [Dash] type LineWidth = Double -- not using line join -- not using line cap -- do we want arrows? data LineOptions = LineOptions DashStyle LineWidth+                 deriving(Eq)  data LineType = NoLine               | ColourLine Color               | TypeLine LineOptions Color+                deriving(Eq)  ----------------------------------------------------------------------------- @@ -181,9 +183,9 @@  type GridLines = Bool type TickValues = Either Int (Vector Double) -- ^ Either (number of ticks) (tick values)-data Ticks = Ticks GridLines TickValues+data Ticks = Ticks LineType TickValues -setTickGridlines :: GridLines -> Ticks -> Ticks+setTickGridlines :: LineType -> Ticks -> Ticks setTickGridlines gl (Ticks _ tv) = Ticks gl tv  setTickValues :: TickValues -> Ticks -> Ticks
plot.cabal view
@@ -1,5 +1,5 @@ Name:                plot-Version:             0.1.2+Version:             0.1.2.1 License:             BSD3 License-file:        LICENSE Copyright:           (c) A.V.H. McPhail 2010@@ -39,7 +39,10 @@      Changes in plot 0.1.2      .           * axis join rendering improvement+     .           * added annotations+     .+          * grid lines formattable      . Category:            Graphics