Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
Graphics.EasyPlot
Description
A simple wrapper to the gnuplot command line utility.
Typically you will invoke a plot like so:
plot X11 $ Data2D [Title "Sample Data"] [] [(1, 2), (2, 4), ...]
To plot a function, use the following:
plot X11 $ Function2D [Title "Sine and Cosine"] [] (\x -> sin x * cos x)
There is also a shortcut available - the following plots the sine function:
plot X11 sin
Output can go into a file, too (See TerminalType
):
plot (PNG "plot.png") (sin . cos)
Haskell functions are plotted via a set of tuples obtained form the function.
If you want to make use of gnuplots mighty function plotting functions you can
pass a Gnuplot2D
or Gnuplot3D
object to plot.
plot X11 $ Gnuplot2D [Color Blue] [] "2**cos(x)"
For 3D-Plots there is a shortcut available by directly passing a String:
plot X11 "x*y"
Multiple graphs can be shown simply by passing a list of these:
plot X11 [ Data2D [Title "Graph 1", Color Red] [] [(x, x ** 3) | x <- [-4,-3.9..4]] , Function2D [Title "Function 2", Color Blue] [] (\x -> negate $ x ** 2) ]
For 3D Graphs it is useful to be able to interact with the graph (See plot'
and GnuplotOption
):
plot' [Interactive] X11 $ Gnuplot3D [Color Magenta] [] "x ** 2 + y ** 3"
If you want to know the command that SimplePlot uses to plot your graph, turn on debugging:
plot' [Debug] X11 $ Gnuplot3D [Color Magenta] [] "x ** 4 + y ** 3" > set term x11 persist; splot x ** 4 + y ** 3 lc rgb "magenta"
Synopsis
- class Plot a where
- plot :: TerminalType -> a -> IO Bool
- plot' :: [GnuplotOption] -> TerminalType -> a -> IO Bool
- data Graph2D x y
- data Graph3D x y z
- data TerminalType
- data Color
- data Style
- = Lines
- | Points
- | Dots
- | Impulses
- | Linespoints
- data Option
- data Option2D x y
- data Option3D x y z
- data GnuplotOption
- = Interactive
- | Debug
Plotting
Provides the plot function for different kinds of graphs (2D and 3D)
Minimal complete definition
Methods
Arguments
:: TerminalType | The terminal to be used for output. |
-> a | |
-> IO Bool | Whether the plot was successfull or not. |
Do a plot to the terminal (i.e. a window will open and your plot can be seen)
plot' :: [GnuplotOption] -> TerminalType -> a -> IO Bool Source #
Instances
Plot String Source # | plot accepts a custom string which is then to be interpreted by gnu plot.
The function will be interpreted as |
Defined in Graphics.EasyPlot Methods plot :: TerminalType -> String -> IO Bool Source # plot' :: [GnuplotOption] -> TerminalType -> String -> IO Bool Source # | |
(Fractional x, Enum x, Show x, Num y, Show y) => Plot [Graph2D x y] Source # | |
Defined in Graphics.EasyPlot Methods plot :: TerminalType -> [Graph2D x y] -> IO Bool Source # plot' :: [GnuplotOption] -> TerminalType -> [Graph2D x y] -> IO Bool Source # | |
(Fractional x, Enum x, Show x, Fractional y, Enum y, Show y, Num z, Show z) => Plot [Graph3D x y z] Source # | |
Defined in Graphics.EasyPlot Methods plot :: TerminalType -> [Graph3D x y z] -> IO Bool Source # plot' :: [GnuplotOption] -> TerminalType -> [Graph3D x y z] -> IO Bool Source # | |
Plot [String] Source # | plots mutliple 3D functions using gnuplots native function parser
and renderer. The String will be interpreted as |
Defined in Graphics.EasyPlot Methods plot :: TerminalType -> [String] -> IO Bool Source # plot' :: [GnuplotOption] -> TerminalType -> [String] -> IO Bool Source # | |
(Fractional x, Enum x, Num x, Show x, Num y, Show y) => Plot [(x, y)] Source # | A list of tuples can be plotted directly using |
Defined in Graphics.EasyPlot Methods plot :: TerminalType -> [(x, y)] -> IO Bool Source # plot' :: [GnuplotOption] -> TerminalType -> [(x, y)] -> IO Bool Source # | |
(Fractional x, Enum x, Show x, Fractional y, Enum y, Show y, Num z, Show z) => Plot [(x, y, z)] Source # | A list of triples can be plotted directly using |
Defined in Graphics.EasyPlot Methods plot :: TerminalType -> [(x, y, z)] -> IO Bool Source # plot' :: [GnuplotOption] -> TerminalType -> [(x, y, z)] -> IO Bool Source # | |
(Fractional x, Enum x, Show x, Fractional y, Enum y, Show y, Num z, Show z) => Plot [x -> y -> z] Source # | A list of 3D functions can be plotted directly using |
Defined in Graphics.EasyPlot Methods plot :: TerminalType -> [x -> y -> z] -> IO Bool Source # plot' :: [GnuplotOption] -> TerminalType -> [x -> y -> z] -> IO Bool Source # | |
(Fractional x, Enum x, Show x, Num y, Show y) => Plot [x -> y] Source # | A list of 2D functions can be plotted directly using |
Defined in Graphics.EasyPlot Methods plot :: TerminalType -> [x -> y] -> IO Bool Source # plot' :: [GnuplotOption] -> TerminalType -> [x -> y] -> IO Bool Source # | |
(Fractional x, Enum x, Show x, Num y, Show y) => Plot (Graph2D x y) Source # | |
Defined in Graphics.EasyPlot Methods plot :: TerminalType -> Graph2D x y -> IO Bool Source # plot' :: [GnuplotOption] -> TerminalType -> Graph2D x y -> IO Bool Source # | |
(Fractional x, Enum x, Show x, Fractional y, Enum y, Show y, Num z, Show z) => Plot (x -> y -> z) Source # | A 3D function can be plotted directly using |
Defined in Graphics.EasyPlot Methods plot :: TerminalType -> (x -> y -> z) -> IO Bool Source # plot' :: [GnuplotOption] -> TerminalType -> (x -> y -> z) -> IO Bool Source # | |
(Fractional x, Enum x, Show x, Num y, Show y) => Plot (x -> y) Source # | A 2D function can be plotted directly using |
Defined in Graphics.EasyPlot Methods plot :: TerminalType -> (x -> y) -> IO Bool Source # plot' :: [GnuplotOption] -> TerminalType -> (x -> y) -> IO Bool Source # | |
(Fractional x, Enum x, Show x, Fractional y, Enum y, Show y, Num z, Show z) => Plot (Graph3D x y z) Source # | |
Defined in Graphics.EasyPlot Methods plot :: TerminalType -> Graph3D x y z -> IO Bool Source # plot' :: [GnuplotOption] -> TerminalType -> Graph3D x y z -> IO Bool Source # |
Graphs for 2D and 3D plots
A two dimensional set of data to plot.
Constructors
Function2D [Option] [Option2D x y] (x -> y) | plots a Haskell function |
Data2D [Option] [Option2D x y] [(x, y)] | plots a set of tuples. |
Gnuplot2D [Option] [Option2D x y] String | plots a custom function passed to Gnuplot (like |
Instances
(Fractional x, Enum x, Show x, Num y, Show y) => Plot [Graph2D x y] Source # | |
Defined in Graphics.EasyPlot Methods plot :: TerminalType -> [Graph2D x y] -> IO Bool Source # plot' :: [GnuplotOption] -> TerminalType -> [Graph2D x y] -> IO Bool Source # | |
(Fractional x, Enum x, Show x, Num y, Show y) => Plot (Graph2D x y) Source # | |
Defined in Graphics.EasyPlot Methods plot :: TerminalType -> Graph2D x y -> IO Bool Source # plot' :: [GnuplotOption] -> TerminalType -> Graph2D x y -> IO Bool Source # |
A three dimensional set of data to plot.
Constructors
Function3D [Option] [Option3D x y z] (x -> y -> z) | plots a Haskell function |
Data3D [Option] [Option3D x y z] [(x, y, z)] | plots a set of triples. |
Gnuplot3D [Option] [Option3D x y z] String | plots a custom function passed to Gnuplot (like |
Instances
(Fractional x, Enum x, Show x, Fractional y, Enum y, Show y, Num z, Show z) => Plot [Graph3D x y z] Source # | |
Defined in Graphics.EasyPlot Methods plot :: TerminalType -> [Graph3D x y z] -> IO Bool Source # plot' :: [GnuplotOption] -> TerminalType -> [Graph3D x y z] -> IO Bool Source # | |
(Fractional x, Enum x, Show x, Fractional y, Enum y, Show y, Num z, Show z) => Plot (Graph3D x y z) Source # | |
Defined in Graphics.EasyPlot Methods plot :: TerminalType -> Graph3D x y z -> IO Bool Source # plot' :: [GnuplotOption] -> TerminalType -> Graph3D x y z -> IO Bool Source # |
Configuration and other options
data TerminalType Source #
TerminalType determines where the output of gnuplot should go.
Constructors
Aqua | Output on Mac OS X (Aqua Terminal). |
Windows | Output for MS Windows. |
X11 | Output to the X Window System. |
PS FilePath | Output into a Postscript file. |
EPS FilePath | Output into an EPS file. |
PNG FilePath | Output as Portable Network Graphic into file. |
PDF FilePath | Output as Portable Document Format into a file. |
SVG FilePath | Output as Scalable Vector Graphic into a file. |
GIF FilePath | Output as Graphics Interchange Format into a file. |
JPEG FilePath | Output into a JPEG file. |
Latex FilePath | Output as LaTeX. |
The Color of a graph.
The Style of a graph.
Constructors
Lines | points in the plot are interconnected by lines. |
Points | data points are little cross symbols. |
Dots | data points are real dots (approx the size of a pixel). |
Impulses | |
Linespoints |
Options on how to render a graph.
Options which are exclusively available for 2D plots.
Options which are exclusively available for 3D plots.
Constructors
RangeX x x | Plots the function for the specified x range |
RangeY y y | Plots the function for the specified y range |
ForX [x] | Plots the function only for the given x values |
ForY [y] | Plots the function only for the given y values |
StepX x | Uses the given step-size for plotting along the x-axis |
StepY y | Uses the given step-size for plotting along the y-axis |
data GnuplotOption Source #
Options which can be used with plot'
Constructors
Interactive | keeps gnuplot open, so that you can interact with the plot (only usefull with |
Debug | prints the command used for running gnuplot. |
Instances
Eq GnuplotOption Source # | |
Defined in Graphics.EasyPlot Methods (==) :: GnuplotOption -> GnuplotOption -> Bool # (/=) :: GnuplotOption -> GnuplotOption -> Bool # |