plot- A plotting library, exportable as eps/pdf/svg/png or renderable with gtk

Maintainerhaskell.vivian.mcphail <at> gmail <dot> com




Creation and manipulation of Figures

The same problem of leaked instances as at occurs here.

with, set, clear, new, and add are the operations that can be performed on various elements of a figure.

glib/data-accessor abstractions (verbs/modifiers) are planned for future implementations


Top level operation

Default options

withTextDefaults :: Text () -> Figure ()Source

perform some actions on the text defaults, must be run before other text element modifications

withLineDefaults :: Line () -> Figure ()Source

perform some actions on the line defaults, must be run before other line element modifications

withPointDefaults :: Point () -> Figure ()Source

perform some actions on the point defaults, must be run before other point modifications

withBarDefaults :: Bar () -> Figure ()Source

perform some actions on the bar defaults, must be run before other point modifications


newFigure :: Figure ()Source

create a new blank Figure


setFigurePadding :: Double -> Double -> Double -> Double -> Figure ()Source

set the padding of the figure

withTitle :: Text () -> Figure ()Source

operate on the title

withSubTitle :: Text () -> Figure ()Source

operate on the sub-title



:: Int


-> Int


-> Figure () 

set the shape of the plots, losing all current plots

withPlot :: (Int, Int) -> Plot () -> Figure ()Source

perform some actions on the specified subplot

withPlots :: Plot () -> Figure ()Source

perform some actions all subplots


data Plot a Source


Monad Plot 
Simple Plot 
MonadReader Options Plot 
MonadState PlotData Plot 
MonadSupply SupplyData Plot 

Plot elements

setBorder :: Border -> Plot ()Source

whether to draw a boundary around the plot area

setPlotPadding :: Double -> Double -> Double -> Double -> Plot ()Source

set the padding of the subplot

withHeading :: Text () -> Plot ()Source

set the heading of the subplot

Series data

class Abscissa a Source


type FormattedSeries = Data DecoratedSeriesSource

data SeriesType Source


(Abscissa a, Ordinate b) => Dataset [(SeriesType, a, b)] 
Ordinate a => Dataset (SeriesType, [a]) 
(Abscissa a, Ordinate b) => Dataset (SeriesType, a, [b]) 

setDataset :: Dataset a => a -> Plot ()Source

set the data series of the subplot

The data series are either FormattedSeries or plain data series. A plain data series must carry a SeriesType.

A dataset may or may not have an abscissa series, and if so, it is paired with either a list of ordinate series or a single ordinate series.

The abscissa series (if present) is of type 'Vector Double'.

An ordinate series be a function (Double -> Double) or a series of points, a 'Vector Double' with optional error series, y axis preference, and labels.

To specify decoration options for an ordinate series, use the appropriate function, such as linespoints, with the ordinate series and decoration formatting (LineFormat, PointFormat, and BarFormat) as arguments.

 setDataset (ts,[linespoints (xs,(le,ue),Upper,"data") (([Dash,Dash],3,blue),(Diamond,green))])

has abscissa ts paired with a list of ordinate series, the single element of which is a FormattedSeries, linespoints where the ordinate is xs with error series le and ue, to be graphed against the upper y-range with label "data". The line element is formatted to be dashed, of width 3, and blue and the point element is to be a green diamond.


data Annote a Source


arrow :: Head -> Location -> Location -> Line () -> Annote ()Source

add an arrow

oval :: Fill -> Location -> Location -> Bar () -> Annote ()Source

add an oval

rect :: Fill -> Location -> Location -> Bar () -> Annote ()Source

add a rectangle

glyph :: Location -> Point () -> Annote ()Source

add a rectangle

text :: Location -> Text () -> Annote ()Source

add text

cairo :: (Double -> Double -> Double -> Double -> Render ()) -> Annote ()Source

add a cairo render that takes the bounding box (in user coordinates) as an argument

Plot type

setSeriesType :: Int -> SeriesType -> Plot ()Source

set the plot type of a given data series

setAllSeriesTypes :: SeriesType -> Plot ()Source

change the plot type of all data series


withSeriesFormat :: PlotFormats m => Int -> m () -> Plot ()Source

format the plot elements of a given series

withAllSeriesFormats :: PlotFormats m => (Int -> m ()) -> Plot ()Source

format the plot elements of all series

the operation to modify the formats is passed the series index. This allows, for example, colours to be selected from a list that gets indexed by the argument

 setColour = withAllSeriesFormats (\i -> do
                                         setLineColour $ [black,blue,red,green,yellow] !! i
                                         setLineWidth 1.0)


data Scale Source




setRange :: AxisType -> AxisSide -> Scale -> Double -> Double -> Plot ()Source

set the axis range

setRangeFromData :: AxisType -> AxisSide -> Scale -> Plot ()Source

set the axis ranges to values based on dataset


data Axis a Source


Monad Axis 
MonadReader Options Axis 
MonadState AxisData Axis 

data AxisType Source




data AxisPosn Source


Side AxisSide 
Value Double 


clearAxes :: Plot ()Source

clear the axes of a subplot

clearAxis :: AxisType -> AxisPosn -> Plot ()Source

clear an axis of a subplot

addAxis :: AxisType -> AxisPosn -> Axis () -> Plot ()Source

add an axis to the subplot

withAxis :: AxisType -> AxisPosn -> Axis () -> Plot ()Source

operate on the given axis


data Legend a Source


Monad Legend 
MonadReader TextOptions Legend 
MonadState (Maybe LegendData) Legend 

clearLegend :: Plot ()Source

clear the legend

setLegend :: LegendBorder -> LegendLocation -> LegendOrientation -> Plot ()Source

set the legend location and orientation

withLegendFormat :: Text () -> Plot ()Source

format the legend text


data Tick Source




type TickValuesSource


 = Either Int (Vector Double)

Either (number of ticks) (tick values)

setTicks :: Tick -> TickValues -> Axis ()Source

format the axis ticks

setGridlines :: Tick -> GridLines -> Axis ()Source

should gridlines be displayed?

setTickLabelFormat :: String -> Axis ()Source

printf format that takes one argument, the tick value

withAxisLabel :: Text () -> Axis ()Source

operate on the axis label

withAxisLine :: Line () -> Axis ()Source

format the axis line

withGridLine :: Tick -> Line () -> Axis ()Source

format the grid lines


data Line a Source


clearLineFormat :: Line ()Source

clear the formatting of a line

setDashStyle :: DashStyle -> Line ()Source

change the dash style of a line

setLineWidth :: LineWidth -> Line ()Source

change the line width of a line

setLineColour :: Color -> Line ()Source

change the line colour of a line


data Point a Source


setGlyph :: Glyph -> Point ()Source

change the glyph of a point

setPointSize :: PointSize -> Point ()Source

change the size of a point

setPointColour :: Color -> Point ()Source

change the colour of a point


data Bar a Source


class BarFormat a Source


BarFormat Width 
Real a => BarFormat (Colour a) 
Real a => BarFormat (Width, Colour a) 
(Real a, Real b) => BarFormat (Width, Colour a, Colour b) 
Real a => BarFormat (Width, Colour a, LineWidth) 
(Real a, Real b) => BarFormat (Width, Colour a, LineWidth, Colour b) 

clearBarFormat :: Bar ()Source

clear the formatting of a line

setBarWidth :: Width -> Bar ()Source

set the width of the bar

setBarColour :: Color -> Bar ()Source

set the colour of the bar

setBarBorderWidth :: LineWidth -> Bar ()Source

set the width of the bar border

setBarBorderColour :: Color -> Bar ()Source

set the colour of the bar border

Text labels

data Text a Source


Monad Text 
MonadReader TextOptions Text 
MonadState TextEntry Text 

A text element must exist for formatting to work

clearText :: Text ()Source

clear the text entry

clearTextFormat :: Text ()Source

set the text formatting to the default

setText :: String -> Text ()Source

set the value of a text entry

setFontFamily :: FontFamily -> Text ()Source

set the font style of a text entry

setFontStyle :: FontStyle -> Text ()Source

set the font style of a text entry

setFontVariant :: Variant -> Text ()Source

set the font variant of a text entry

setFontWeight :: Weight -> Text ()Source

set the font weight of a text entry

setFontStretch :: Stretch -> Text ()Source

set the font stretch of a text entry

setFontSize :: FontSize -> Text ()Source

set the font size of a text entry

setFontColour :: Color -> Text ()Source

set the colour of a text entry