| Copyright | (c) A. V. H. McPhail 2010 |
|---|---|
| License | BSD3 |
| Maintainer | haskell.vivian.mcphail <at> gmail <dot> com |
| Stability | provisional |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell98 |
Graphics.Rendering.Plot.Figure
Contents
Description
Creation and manipulation of Figures
The same problem of leaked instances as at http://hackage.haskell.org/packages/archive/graphviz/2999.10.0.1/doc/html/Data-GraphViz-Commands.html#t%3AGraphvizCanvas 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
- module Data.Colour.Names
- data Figure a
- data FigureState
- withTextDefaults :: Text () -> Figure ()
- withLineDefaults :: Line () -> Figure ()
- withPointDefaults :: Point () -> Figure ()
- withBarDefaults :: Bar () -> Figure ()
- newFigure :: Figure ()
- setBackgroundColour :: Color -> Figure ()
- setFigurePadding :: Double -> Double -> Double -> Double -> Figure ()
- withTitle :: Text () -> Figure ()
- withSubTitle :: Text () -> Figure ()
- setPlots :: Int -> Int -> Figure ()
- withPlot :: (Int, Int) -> Plot () -> Figure ()
- withPlots :: Plot () -> Figure ()
- data Plot a
- setPlotBackgroundColour :: Color -> Plot ()
- type Border = Bool
- setBorder :: Border -> Plot ()
- setPlotPadding :: Double -> Double -> Double -> Double -> Plot ()
- withHeading :: Text () -> Plot ()
- type Function = Double -> Double
- type VectorFunction = Vector Double -> Vector Double
- type Series = Vector Double
- type MinMaxSeries = (Series, Series)
- type ErrorSeries = Series
- type Surface = Matrix Double
- type SeriesLabel = String
- class Abscissa a
- class Ordinate a
- class Dataset a
- type FormattedSeries = Data DecoratedSeries
- data SeriesType
- line :: (Ordinate a, LineFormat b) => a -> b -> FormattedSeries
- point :: (Ordinate a, PointFormat b) => a -> b -> FormattedSeries
- linepoint :: (Ordinate a, LineFormat b, PointFormat c) => a -> b -> c -> FormattedSeries
- impulse :: (Ordinate a, LineFormat b) => a -> b -> FormattedSeries
- step :: (Ordinate a, LineFormat b) => a -> b -> FormattedSeries
- area :: (Ordinate a, LineFormat b) => a -> b -> FormattedSeries
- bar :: (Ordinate a, BarFormat b) => a -> b -> FormattedSeries
- hist :: (Ordinate a, BarFormat b) => a -> b -> FormattedSeries
- candle :: (Ordinate a, BarFormat b) => a -> b -> FormattedSeries
- whisker :: (Ordinate a, BarFormat b) => a -> b -> FormattedSeries
- setDataset :: Dataset a => a -> Plot ()
- type Location = (Double, Double)
- type Head = Bool
- type Fill = Bool
- data Annote a
- arrow :: Head -> Location -> Location -> Line () -> Annote ()
- oval :: Fill -> Location -> Location -> Bar () -> Annote ()
- rect :: Fill -> Location -> Location -> Bar () -> Annote ()
- glyph :: Location -> Point () -> Annote ()
- text :: Location -> Text () -> Annote ()
- cairo :: (Double -> Double -> Double -> Double -> Render ()) -> Annote ()
- withAnnotations :: Annote () -> Plot ()
- setSeriesType :: Int -> SeriesType -> Plot ()
- setAllSeriesTypes :: SeriesType -> Plot ()
- class PlotFormats m
- withSeriesFormat :: PlotFormats m => Int -> m () -> Plot ()
- withAllSeriesFormats :: PlotFormats m => (Int -> m ()) -> Plot ()
- data Scale
- setRange :: AxisType -> AxisSide -> Scale -> Double -> Double -> Plot ()
- setRangeFromData :: AxisType -> AxisSide -> Scale -> Plot ()
- data Axis a
- data AxisType
- data AxisSide
- data AxisPosn
- clearAxes :: Plot ()
- clearAxis :: AxisType -> AxisPosn -> Plot ()
- addAxis :: AxisType -> AxisPosn -> Axis () -> Plot ()
- withAxis :: AxisType -> AxisPosn -> Axis () -> Plot ()
- data BarSetting
- barSetting :: BarSetting -> Plot ()
- type SampleData = Bool
- sampleData :: SampleData -> Plot ()
- data Legend a
- type LegendBorder = Bool
- data LegendLocation
- data LegendOrientation
- clearLegend :: Plot ()
- setLegend :: LegendBorder -> LegendLocation -> LegendOrientation -> Plot ()
- withLegendFormat :: Text () -> Plot ()
- data Tick
- data TickValues
- = TickNumber Int
- | TickValues (Vector Double)
- type GridLines = Bool
- data TickFormat
- = DefaultTickFormat
- | Printf String
- | FormatFunction (Double -> String)
- setTicks :: Tick -> TickValues -> Axis ()
- setGridlines :: Tick -> GridLines -> Axis ()
- setTickLabelFormat :: TickFormat -> Axis ()
- setTickLabels :: [String] -> Axis ()
- withTickLabelsFormat :: Text () -> Axis ()
- withAxisLabel :: Text () -> Axis ()
- withAxisLine :: Line () -> Axis ()
- withGridLine :: Tick -> Line () -> Axis ()
- data Line a
- class LineFormat a
- type DashStyle = [Dash]
- data Dash
- type LineWidth = Double
- clearLineFormat :: Line ()
- setDashStyle :: DashStyle -> Line ()
- setLineWidth :: LineWidth -> Line ()
- setLineColour :: Color -> Line ()
- data Point a
- class PointFormat a
- data Glyph
- type PointSize = Double
- setGlyph :: Glyph -> Point ()
- setPointSize :: PointSize -> Point ()
- setPointColour :: Color -> Point ()
- data Bar a
- class BarFormat a
- clearBarFormat :: Bar ()
- setBarWidth :: Width -> Bar ()
- setBarColour :: Color -> Bar ()
- setBarBorderWidth :: LineWidth -> Bar ()
- setBarBorderColour :: Color -> Bar ()
- data Text a
- type FontFamily = String
- type FontSize = Double
- type Color = Colour Double
- clearText :: Text ()
- clearTextFormat :: Text ()
- setText :: String -> Text ()
- setFontFamily :: FontFamily -> Text ()
- setFontStyle :: FontStyle -> Text ()
- setFontVariant :: Variant -> Text ()
- setFontWeight :: Weight -> Text ()
- setFontStretch :: Stretch -> Text ()
- setFontSize :: FontSize -> Text ()
- setFontColour :: Color -> Text ()
Documentation
module Data.Colour.Names
Top level operation
data FigureState #
Instances
Default options
withTextDefaults :: Text () -> Figure () #
perform some actions on the text defaults, must be run before other text element modifications
withLineDefaults :: Line () -> Figure () #
perform some actions on the line defaults, must be run before other line element modifications
withPointDefaults :: Point () -> Figure () #
perform some actions on the point defaults, must be run before other point modifications
withBarDefaults :: Bar () -> Figure () #
perform some actions on the bar defaults, must be run before other point modifications
Figures
Formatting
setBackgroundColour :: Color -> Figure () #
set the background colour of the figure
setFigurePadding :: Double -> Double -> Double -> Double -> Figure () #
set the padding of the figure
withSubTitle :: Text () -> Figure () #
operate on the sub-title
set the shape of the plots, losing all current plots
Sub-plots
Colour
setPlotBackgroundColour :: Color -> Plot () #
set the plot background colour
Plot elements
withHeading :: Text () -> Plot () #
set the heading of the subplot
Series data
type MinMaxSeries = (Series, Series) #
type ErrorSeries = Series #
type SeriesLabel = String #
Minimal complete definition
toOrdinate
Instances
Minimal complete definition
toDataSeries
Instances
| Dataset Surface # | |
| Abscissa a => Dataset [(a, FormattedSeries)] # | |
| (Abscissa a, Ordinate b) => Dataset [(SeriesType, a, b)] # | |
| Dataset [FormattedSeries] # | |
| Abscissa a => Dataset (a, [FormattedSeries]) # | |
| Ordinate a => Dataset (SeriesType, [a]) # | |
| (Abscissa a, Ordinate b) => Dataset (SeriesType, a, [b]) # | |
type FormattedSeries = Data DecoratedSeries #
data SeriesType #
Instances
| (Abscissa a, Ordinate b) => Dataset [(SeriesType, a, b)] # | |
| Ordinate a => Dataset (SeriesType, [a]) # | |
| (Abscissa a, Ordinate b) => Dataset (SeriesType, a, [b]) # | |
line :: (Ordinate a, LineFormat b) => a -> b -> FormattedSeries #
point :: (Ordinate a, PointFormat b) => a -> b -> FormattedSeries #
linepoint :: (Ordinate a, LineFormat b, PointFormat c) => a -> b -> c -> FormattedSeries #
impulse :: (Ordinate a, LineFormat b) => a -> b -> FormattedSeries #
step :: (Ordinate a, LineFormat b) => a -> b -> FormattedSeries #
area :: (Ordinate a, LineFormat b) => a -> b -> FormattedSeries #
bar :: (Ordinate a, BarFormat b) => a -> b -> FormattedSeries #
hist :: (Ordinate a, BarFormat b) => a -> b -> FormattedSeries #
candle :: (Ordinate a, BarFormat b) => a -> b -> FormattedSeries #
whisker :: (Ordinate a, BarFormat b) => a -> b -> FormattedSeries #
setDataset :: Dataset a => a -> Plot () #
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.
Annotations
cairo :: (Double -> Double -> Double -> Double -> Render ()) -> Annote () #
add a cairo render that takes the bounding box (in user coordinates) as an argument
withAnnotations :: Annote () -> Plot () #
Plot type
setSeriesType :: Int -> SeriesType -> Plot () #
set the plot type of a given data series
setAllSeriesTypes :: SeriesType -> Plot () #
change the plot type of all data series
Formatting
withSeriesFormat :: PlotFormats m => Int -> m () -> Plot () #
format the plot elements of a given series
withAllSeriesFormats :: PlotFormats m => (Int -> m ()) -> Plot () #
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)Range
setRangeFromData :: AxisType -> AxisSide -> Scale -> Plot () #
set the axis ranges to values based on dataset
Axes
Instances
| Eq AxisSide # | |
| Ordinate (VectorFunction, AxisSide) # | |
| Ordinate (Function, AxisSide) # | |
| Ordinate (Series, AxisSide) # | |
| Ordinate (VectorFunction, AxisSide, SeriesLabel) # | |
| Ordinate (Function, AxisSide, SeriesLabel) # | |
| Ordinate (MinMaxSeries, (ErrorSeries, ErrorSeries), AxisSide) # | |
| Ordinate (Series, (ErrorSeries, ErrorSeries), AxisSide) # | |
| Ordinate (Series, ErrorSeries, AxisSide) # | |
| Ordinate (Series, AxisSide, SeriesLabel) # | |
| Ordinate (MinMaxSeries, (ErrorSeries, ErrorSeries), AxisSide, SeriesLabel) # | |
| Ordinate (Series, (ErrorSeries, ErrorSeries), AxisSide, SeriesLabel) # | |
| Ordinate (Series, ErrorSeries, AxisSide, SeriesLabel) # | |
BarSetting
data BarSetting #
barSetting :: BarSetting -> Plot () #
Data Sampling
type SampleData = Bool #
sampleData :: SampleData -> Plot () #
Legend
type LegendBorder = Bool #
data LegendLocation #
Instances
data LegendOrientation #
clearLegend :: Plot () #
clear the legend
setLegend :: LegendBorder -> LegendLocation -> LegendOrientation -> Plot () #
set the legend location and orientation
withLegendFormat :: Text () -> Plot () #
format the legend text
Formatting
data TickValues #
Constructors
| TickNumber Int | |
| TickValues (Vector Double) |
data TickFormat #
Constructors
| DefaultTickFormat | |
| Printf String | |
| FormatFunction (Double -> String) |
setTicks :: Tick -> TickValues -> Axis () #
format the axis ticks
setGridlines :: Tick -> GridLines -> Axis () #
should gridlines be displayed?
setTickLabelFormat :: TickFormat -> Axis () #
set the tick label format
setTickLabels :: [String] -> Axis () #
a list of data labels
withTickLabelsFormat :: Text () -> Axis () #
format the tick labels
withAxisLabel :: Text () -> Axis () #
operate on the axis label
withAxisLine :: Line () -> Axis () #
format the axis line
withGridLine :: Tick -> Line () -> Axis () #
format the grid lines
Lines
class LineFormat a #
Minimal complete definition
toLine
Instances
| LineFormat LineWidth # | |
| LineFormat DashStyle # | |
| Real a => LineFormat (Colour a) # | |
| Real a => LineFormat (LineWidth, Colour a) # | |
| Real a => LineFormat (DashStyle, Colour a) # | |
| LineFormat (DashStyle, LineWidth) # | |
| Real a => LineFormat (DashStyle, LineWidth, Colour a) # | |
clearLineFormat :: Line () #
clear the formatting of a line
setDashStyle :: DashStyle -> Line () #
change the dash style of a line
setLineWidth :: LineWidth -> Line () #
change the line width of a line
setLineColour :: Color -> Line () #
change the line colour of a line
Points
class PointFormat a #
Minimal complete definition
toPoint
Instances
| PointFormat Glyph # | |
| Real a => PointFormat (Colour a) # | |
| Real a => PointFormat (Glyph, Colour a) # | |
| PointFormat (Glyph, PointSize) # | |
| Real a => PointFormat (Glyph, PointSize, Colour a) # | |
Instances
| PointFormat Glyph # | |
| Real a => PointFormat (Glyph, Colour a) # | |
| PointFormat (Glyph, PointSize) # | |
| Real a => PointFormat (Glyph, PointSize, Colour a) # | |
setPointSize :: PointSize -> Point () #
change the size of a point
setPointColour :: Color -> Point () #
change the colour of a point
Bars
clearBarFormat :: Bar () #
clear the formatting of a line
setBarWidth :: Width -> Bar () #
set the width of the bar
setBarColour :: Color -> Bar () #
set the colour of the bar
setBarBorderWidth :: LineWidth -> Bar () #
set the width of the bar border
setBarBorderColour :: Color -> Bar () #
set the colour of the bar border
Text labels
type FontFamily = String #
A text element must exist for formatting to work
clearTextFormat :: Text () #
set the text formatting to the default
setFontFamily :: FontFamily -> Text () #
set the font style of a text entry
setFontStyle :: FontStyle -> Text () #
set the font style of a text entry
setFontVariant :: Variant -> Text () #
set the font variant of a text entry
setFontWeight :: Weight -> Text () #
set the font weight of a text entry
setFontStretch :: Stretch -> Text () #
set the font stretch of a text entry
setFontSize :: FontSize -> Text () #
set the font size of a text entry
setFontColour :: Color -> Text () #
set the colour of a text entry