packages feed

matplotlib 0.1.0.0 → 0.1.1.0

raw patch · 2 files changed

+15/−3 lines, 2 files

Files

matplotlib.cabal view
@@ -1,5 +1,5 @@ name:                matplotlib-version:             0.1.0.0+version:             0.1.1.0 synopsis:            Bindings to Matplotlib; a Python plotting library description:         Matplotlib is probably the most full featured plotting library out there. These bindings provide a quick, easy, and extensible way to use it in Haskell. Type-safety is largely non-existent and sacrificed for maximum extensibility. homepage:            https://github.com/abarbu/matplotlib-haskell
src/Graphics/Matplotlib.hs view
@@ -48,9 +48,13 @@  -- | Throughout the API we need to accept options in order to expose -- matplotlib's many configuration options.-data Option = K String String -- | results in a=b-            | B String        -- | just inserts the option verbatim as an argument at the end of the function+data Option =+   -- | results in a=b+  K String String+  -- | just inserts the option verbatim as an argument at the end of the function+  | B String +-- | Convert an 'MplotCommand' to python code, doesn't do much right now toPy (LoadData _) = error "withMplot needed to load data" toPy (Exec str)   = str @@ -80,6 +84,7 @@              Right <$> readProcess "/usr/bin/python3" [codeFile] ""))          (\e -> return $ Left $ show (e :: IOException)) +-- | The standard python includes of every plot pyIncludes = ["import matplotlib"              -- TODO Provide a way to set the render backend              -- ,"matplotlib.use('GtkAgg')"@@ -96,15 +101,19 @@              ,"import random, datetime"              ,"from matplotlib.dates import DateFormatter, WeekdayLocator"] +-- | The python command that reads external data into the python data array pyReadData filename = ["data = json.loads(open('" ++ filename ++ "').read())"] +-- | Detach python so we don't block (TODO This isn't working reliably) pyDetach = ["pid = os.fork()"            ,"if(pid != 0):"            ,"  exit(0)"] +-- | Python code to show a plot pyOnscreen = ["plot.draw()"              ,"plot.show()"] +-- | Python code that saves a figure pyFigure output = ["plot.savefig('" ++ output ++ "')"]  --- Running a plot@@ -120,6 +129,7 @@  -- Creating matplotlib computations +-- | Create a plot that executes the string as python code mplot s = Matplotlib [Exec s]  infixl 5 %@@ -184,6 +194,8 @@ options [] = "" options xs = "," # xs +-- | Combine a list of user options with a default; useful for options such as+-- line styles that require sane defaults but can be overriden. def o [] = [o] def o l@((B _):_) = l def o (x:xs) = x : def o xs