plot 0.1.7.1 → 0.1.8
raw patch · 9 files changed
+27/−15 lines, 9 files
Files
- CHANGES +3/−0
- THANKS +1/−0
- lib/Graphics/Rendering/Plot/Defaults.hs +1/−1
- lib/Graphics/Rendering/Plot/Figure.hs +1/−0
- lib/Graphics/Rendering/Plot/Figure/Plot.hs +1/−0
- lib/Graphics/Rendering/Plot/Figure/Plot/Axis.hs +4/−3
- lib/Graphics/Rendering/Plot/Render/Plot/Axis.hs +11/−9
- lib/Graphics/Rendering/Plot/Types.hs +4/−1
- plot.cabal +1/−1
CHANGES view
@@ -98,3 +98,6 @@ 0.1.7.1: * small bug fix when setting ticks++0.1.8:+ * added `TickFormat` data type
THANKS view
@@ -1,2 +1,3 @@ * Nicolas Dudebout for linlog and loglin in Simple.hs * uriba for a small bug fix when setting ticks+ * buecking added the TickFormat data type and resulting code
lib/Graphics/Rendering/Plot/Defaults.hs view
@@ -166,7 +166,7 @@ defaultMajorTicks = Just $ Ticks NoLine (TickNumber 5) defaultTickFormat :: TickFormat-defaultTickFormat = ""+defaultTickFormat = DefaultTickFormat defaultAxis :: AxisType -> AxisPosn -> AxisData defaultAxis at axp = Axis at axp
lib/Graphics/Rendering/Plot/Figure.hs view
@@ -97,6 +97,7 @@ , withLegendFormat -- ** Formatting , Tick(..), TickValues(..), GridLines+ , TickFormat(..) , setTicks , setGridlines , setTickLabelFormat
lib/Graphics/Rendering/Plot/Figure/Plot.hs view
@@ -66,6 +66,7 @@ , withLegendFormat -- ** Formatting , Tick(..), TickValues(..), GridLines+ , TickFormat(..) , AX.setTicks , AX.setGridlines , AX.setTickLabelFormat
lib/Graphics/Rendering/Plot/Figure/Plot/Axis.hs view
@@ -16,6 +16,7 @@ Axis , AxisType(..),AxisSide(..),AxisPosn(..) , Tick(..), TickValues(..), GridLines+ , TickFormat(..) , setTicks , setGridlines , setTickLabelFormat@@ -89,7 +90,7 @@ setTicks Minor (TickNumber 0) = modify $ \s -> changeMinorTicks (const Nothing) s setTicks Minor ts = modify $ \s -> - changeMajorTicks (setTickValues ts) s+ changeMinorTicks (setTickValues ts) s setTicks Major (TickNumber 0) = modify $ \s -> changeMajorTicks (const Nothing) s setTicks Major ts = modify $ \s -> @@ -100,8 +101,8 @@ 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 ()+-- | set the tick label format+setTickLabelFormat :: TickFormat -> Axis () setTickLabelFormat tf = modify $ \s -> changeTickFormat tf s -- | a list of data labels
lib/Graphics/Rendering/Plot/Render/Plot/Axis.hs view
@@ -476,7 +476,7 @@ (Side _) -> True (Value _) -> False when (t == Major && majlab) $ do- let s = if sc == Log then formatTick "10e%.1g" (logBase 10 v) else formatTick tf v+ let s = if sc == Log then formatTick (Printf "10e%.1g") (logBase 10 v) else formatTick tf v let s' = case dl of Nothing -> BareText s Just d -> d@@ -510,13 +510,15 @@ ----------------------------------------------------------------------------- -formatTick :: String -> Double -> String-formatTick tf p- | tf /= "" = Printf.printf tf p - | p == 0.0 = "0"- | abs p > 1000 = Printf.printf "%1.1e" p- | abs p < 0.001 = Printf.printf "%.3e" p- | otherwise = Printf.printf "%.2f" p--- %g uses "whichever of %f, %e is smaller+formatTick :: TickFormat -> Double -> String+formatTick tf p = case tf of+ DefaultTickFormat+ | p == 0.0 -> "0"+ | abs p > 1000 -> Printf.printf "%1.1e" p+ | abs p < 0.001 -> Printf.printf "%.3e" p+ | otherwise -> Printf.printf "%.2f" p+ -- %g uses "whichever of %f, %e is smaller+ Printf s -> Printf.printf s p+ FormatFunction f -> f p -----------------------------------------------------------------------------
lib/Graphics/Rendering/Plot/Types.hs view
@@ -196,7 +196,10 @@ setTickValues tv (Just (Ticks gl _)) = Just $ Ticks gl tv setTickValues tv Nothing = Just $ Ticks NoLine tv -type TickFormat = String+data TickFormat+ = DefaultTickFormat+ | Printf String+ | FormatFunction (Double -> String) data AxisData = Axis { _axis_type :: AxisType
plot.cabal view
@@ -1,5 +1,5 @@ Name: plot-Version: 0.1.7.1+Version: 0.1.8 License: BSD3 License-file: LICENSE Copyright: (c) A.V.H. McPhail 2010, 2012