summaryrefslogtreecommitdiff
path: root/lib/Graphics
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Graphics')
-rw-r--r--lib/Graphics/Plot.hs23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/Graphics/Plot.hs b/lib/Graphics/Plot.hs
index b3cf9d9..510e1b7 100644
--- a/lib/Graphics/Plot.hs
+++ b/lib/Graphics/Plot.hs
@@ -51,7 +51,7 @@ meshdom :: Vector Double -> Vector Double -> (Matrix Double , Matrix Double)
51meshdom r1 r2 = (outer r1 (constant 1 (size r2)), outer (constant 1 (size r1)) r2) 51meshdom r1 r2 = (outer r1 (constant 1 (size r2)), outer (constant 1 (size r1)) r2)
52 52
53gnuplotX :: String -> IO () 53gnuplotX :: String -> IO ()
54gnuplotX command = do {system cmdstr; return()} where 54gnuplotX command = do { _ <- system cmdstr; return()} where
55 cmdstr = "echo \""++command++"\" | gnuplot -persist" 55 cmdstr = "echo \""++command++"\" | gnuplot -persist"
56 56
57datafollows = "\\\"-\\\"" 57datafollows = "\\\"-\\\""
@@ -76,8 +76,8 @@ mesh' m = do
76 writeFile "splot-gnu-command" "splot \"splot-tmp.txt\" matrix with lines; pause -1"; 76 writeFile "splot-gnu-command" "splot \"splot-tmp.txt\" matrix with lines; pause -1";
77 toFile' "splot-tmp.txt" m 77 toFile' "splot-tmp.txt" m
78 putStr "Press [Return] to close the graphic and continue... " 78 putStr "Press [Return] to close the graphic and continue... "
79 system "gnuplot -persist splot-gnu-command" 79 _ <- system "gnuplot -persist splot-gnu-command"
80 system "rm splot-tmp.txt splot-gnu-command" 80 _ <- system "rm splot-tmp.txt splot-gnu-command"
81 return () 81 return ()
82 82
83{- | Draws the surface represented by the function f in the desired ranges and number of points, internally using 'mesh'. 83{- | Draws the surface represented by the function f in the desired ranges and number of points, internally using 'mesh'.
@@ -161,7 +161,7 @@ matrixToPGM m = header ++ unlines (map unwords ll) where
161-- | imshow shows a representation of a matrix as a gray level image using ImageMagick's display. 161-- | imshow shows a representation of a matrix as a gray level image using ImageMagick's display.
162imshow :: Matrix Double -> IO () 162imshow :: Matrix Double -> IO ()
163imshow m = do 163imshow m = do
164 system $ "echo \""++ matrixToPGM m ++"\"| display -antialias -resize 300 - &" 164 _ <- system $ "echo \""++ matrixToPGM m ++"\"| display -antialias -resize 300 - &"
165 return () 165 return ()
166 166
167---------------------------------------------------- 167----------------------------------------------------
@@ -173,12 +173,12 @@ gnuplotpdf title command ds = gnuplot (prelude ++ command ++" "++ draw) >> postp
173 draw = concat (intersperse ", " (map ("\"-\" "++) defs)) ++ "\n" ++ 173 draw = concat (intersperse ", " (map ("\"-\" "++) defs)) ++ "\n" ++
174 concatMap pr dats 174 concatMap pr dats
175 postproc = do 175 postproc = do
176 system $ "epstopdf "++title++".eps" 176 _ <- system $ "epstopdf "++title++".eps"
177 mklatex 177 mklatex
178 system $ "pdflatex "++title++"aux.tex > /dev/null" 178 _ <- system $ "pdflatex "++title++"aux.tex > /dev/null"
179 system $ "pdfcrop "++title++"aux.pdf > /dev/null" 179 _ <- system $ "pdfcrop "++title++"aux.pdf > /dev/null"
180 system $ "mv "++title++"aux-crop.pdf "++title++".pdf" 180 _ <- system $ "mv "++title++"aux-crop.pdf "++title++".pdf"
181 system $ "rm "++title++"aux.* "++title++".eps "++title++".tex" 181 _ <- system $ "rm "++title++"aux.* "++title++".eps "++title++".tex"
182 return () 182 return ()
183 183
184 mklatex = writeFile (title++"aux.tex") $ 184 mklatex = writeFile (title++"aux.tex") $
@@ -201,5 +201,6 @@ gnuplotpdf title command ds = gnuplot (prelude ++ command ++" "++ draw) >> postp
201 201
202 gnuplot cmd = do 202 gnuplot cmd = do
203 writeFile "gnuplotcommand" cmd 203 writeFile "gnuplotcommand" cmd
204 system "gnuplot gnuplotcommand" 204 _ <- system "gnuplot gnuplotcommand"
205 system "rm gnuplotcommand" 205 _ <- system "rm gnuplotcommand"
206 return ()