packages feed

matplotlib 0.7.6 → 0.7.7

raw patch · 3 files changed

+32/−27 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Graphics.Matplotlib: def :: Matplotlib -> [Option] -> Matplotlib
- Graphics.Matplotlib.Internal: def :: Matplotlib -> [Option] -> Matplotlib
- Graphics.Matplotlib.Internal: defFn :: [Option] -> [Option] -> [Option]
+ Graphics.Matplotlib: bindDefault :: Matplotlib -> [Option] -> Matplotlib
+ Graphics.Matplotlib.Internal: bindDefault :: Matplotlib -> [Option] -> Matplotlib
+ Graphics.Matplotlib.Internal: bindDefaultFn :: [Option] -> [Option] -> [Option]

Files

matplotlib.cabal view
@@ -1,5 +1,5 @@ name:                matplotlib-version:             0.7.6+version:             0.7.7 synopsis:            Bindings to Matplotlib; a Python plotting library description:     Matplotlib is probably the most full featured plotting library out there.
src/Graphics/Matplotlib.hs view
@@ -4,20 +4,23 @@ -- Matplotlib bindings and an interface to easily bind to new portions of the -- API. The most essential parts of Matplotlib are wrapped and exposed to -- Haskell through an interface that allows extenisbility. Code is generated on--- the fly and python is called.+-- the fly and Python is called. ----- This is not a very Haskell-ish library. Type safety is non-existent, it's--- easy to generate incorrect Python code, in exchange for being able to bind to+-- You should start by looking at the tests, they demonstrate how to create many+-- different types of plots.+--+-- This is not a very Haskell-ish library. Type safety is non-existent. It's+-- easy to generate incorrect Python code. But in exchange, we can bind to -- arbitrary matplotlib APIs with ease, so it's also easy to generate correct--- python code.+-- Python code. ----- The generated code follows a few simple conventions.  data is always loaded--- into a data variable that is a python array. Data is transffered via--- json. This data variable is indexed by various rendering commands.+-- The generated code follows a few simple conventions. Data is always loaded+-- into a data variable that is a Python array. Data is transffered via+-- JSON. This data variable is indexed by various rendering commands. -- -- Functions which start with the word data operate on the data array, arguments--- are python code that should access that array. Most other functions take--- haskell objects and load them into python.+-- are Python code that should access that array. Most other functions take+-- Haskell objects and load them into Python. -- -- This module should expose enough tools so that you can bind any part of the -- matplotlib API. A binding with options, such as that of 'plot', looks like:@@ -30,11 +33,13 @@ -- -- Where important functions are: -----   [@'readData'@] Load the given data into the python data array by serializing it to JSON.+--   [@'readData'@] Load the given data by serializing it to JSON and place it in a Python array named "data".+--   [@'readImage'@] Load an image from a given path and place it in a Python variable named "img". --   [@'%'@] Sequence two plots --   [@'mp'@] Create an empty plot---   [@'#'@] Append python code to the last command in a plot+--   [@'#'@] Append Python code to the last command in a plot --   [@'##'@] Just like '#' but also adds in a placeholder for an options list+--   [@'bindDefault'@] Set a default in the last options list, keeping it open for additions -- -- You can call this plot with --@@ -42,8 +47,8 @@ -- -- where '@@' applies an options list replacing the last '##' -----  [@'o1'@] A single positional option. The value is rendered into python as---  the appropriate datatype. Strings become python strings, bools become bools,+--  [@'o1'@] A single positional option. The value is rendered into Python as+--  the appropriate datatype. Strings become Python strings, bools become bools, --  etc. If you want to insert code verbatim into an option use 'lit'. If you --  want to have a raw string with no escapes use 'raw'. --  [@'o2'@] A keyword option. The key is always a string, the value is treated@@ -58,13 +63,13 @@ -- itself; the two APIs are almost identical. When creating low-level bindings -- one must remember to call "plot.sci" to set the current image when plotting a -- graph. The current spine of the axes that's being manipulated is in--- "spine". The current quiver is in "q"+-- "spine". The current quiver is in "q". -----------------------------------------------------------------------------  module Graphics.Matplotlib   ( module Graphics.Matplotlib     -- * Creating custom plots and applying options-  , Matplotlib(), Option(),(@@), (%), o1, o2, (##), (#), mp, def, readData, readImage+  , Matplotlib(), Option(),(@@), (%), o1, o2, (##), (#), mp, bindDefault, readData, readImage   , str, raw, lit, updateAxes, updateFigure, mapLinear) where import Data.List@@ -125,7 +130,7 @@  -- | Plot a line line :: (ToJSON t1, ToJSON t) => t1 -> t -> Matplotlib-line x y = plot x y `def` [o1 "-"]+line x y = plot x y `bindDefault` [o1 "-"]  -- | Like 'plot' but takes an error bar value per point -- errorbar :: (ToJSON x, ToJSON y, ToJSON xs, ToJSON ys) => x -> y -> Maybe xs -> Maybe ys -> Matplotlib@@ -135,7 +140,7 @@ -- | Plot a line given a function that will be executed for each element of -- given list. The list provides the x values, the function the y values. lineF :: (ToJSON a, ToJSON b) => (a -> b) -> [a] -> Matplotlib-lineF f l = plot l (map f l) `def` [o1 "-"]+lineF f l = plot l (map f l) `bindDefault` [o1 "-"]  -- | Create a box plot for the given data boxplot d = readData d@@ -166,7 +171,7 @@ plotInterpolated x y n =   readData (x, y)   % interpolate 0 1 n-  % dataPlot 0 1 `def` [o1 "-"]+  % dataPlot 0 1 `bindDefault` [o1 "-"]  -- | A handy function to plot a line between two points give a function and a number o steps plotMapLinear :: ToJSON b => (Double -> b) -> Double -> Double -> Double -> Matplotlib@@ -246,7 +251,7 @@ dateLine x y xunit (yearStart, monthStart, dayStart) =     readData (x, y)   % mp # "data[0] = [datetime.timedelta("#xunit#"=i) + datetime.datetime("#yearStart#","#monthStart#","#dayStart#") for i in data[0]]"-  % dataPlot 0 1 `def` [o1 "-"]+  % dataPlot 0 1 `bindDefault` [o1 "-"]   % mp # "ax.xaxis.set_major_formatter(DateFormatter('%B'))"   % mp # "ax.xaxis.set_minor_locator(WeekdayLocator(byweekday=6))" @@ -256,11 +261,11 @@  -- | Create a scatter plot accessing the given fields of the data array dataScatter :: (MplotValue val1, MplotValue val) => val1 -> val -> Matplotlib-dataScatter a b = dataPlot a b `def` [o1 "."]+dataScatter a b = dataPlot a b `bindDefault` [o1 "."]  -- | Create a line accessing the given entires of the data array dataLine :: (MplotValue val1, MplotValue val) => val1 -> val -> Matplotlib-dataLine a b = dataPlot a b `def` [o1 "-"]+dataLine a b = dataPlot a b `bindDefault` [o1 "-"]  -- | Create a 3D contour contour xs ys zs =
src/Graphics/Matplotlib/Internal.hs view
@@ -295,13 +295,13 @@ m @@ os = option m os  -- | Bind a list of default options to a plot. Positional options are kept in--- order and default that way as well. Keyword arguments are-def :: Matplotlib -> [Option] -> Matplotlib-def m os = optionFn (defFn os) m+-- order and default that way as well. Keyword arguments are also handled+bindDefault :: Matplotlib -> [Option] -> Matplotlib+bindDefault m os = optionFn (bindDefaultFn os) m  -- | Merge two sets of options-defFn :: [Option] -> [Option] -> [Option]-defFn os os' = merge ps' ps ++ (nub $ ks' ++ ks)+bindDefaultFn :: [Option] -> [Option] -> [Option]+bindDefaultFn os os' = merge ps' ps ++ (nub $ ks' ++ ks)            where isK (K _ _) = True                  isK _ = False                  isP (P _) = True