| Copyright | (c) 2025 |
|---|---|
| License | MIT |
| Maintainer | mschavinda@gmail.com |
| Safe Haskell | None |
| Language | GHC2021 |
Granite.Svg
Description
Synopsis
- data Plot = Plot {
- widthChars :: Int
- heightChars :: Int
- leftMargin :: Int
- bottomMargin :: Int
- titleMargin :: Int
- xBounds :: (Maybe Double, Maybe Double)
- yBounds :: (Maybe Double, Maybe Double)
- plotTitle :: Text
- legendPos :: LegendPos
- colorPalette :: [Color]
- xFormatter :: LabelFormatter
- yFormatter :: LabelFormatter
- xNumTicks :: Int
- yNumTicks :: Int
- defPlot :: Plot
- data LegendPos
- data Color where
- Color !Word8 !Word8 !Word8
- pattern Black :: Color
- pattern Red :: Color
- pattern Green :: Color
- pattern Yellow :: Color
- pattern Blue :: Color
- pattern Magenta :: Color
- pattern Cyan :: Color
- pattern White :: Color
- pattern BrightBlack :: Color
- pattern BrightRed :: Color
- pattern BrightGreen :: Color
- pattern BrightYellow :: Color
- pattern BrightBlue :: Color
- pattern BrightMagenta :: Color
- pattern BrightCyan :: Color
- pattern BrightWhite :: Color
- pattern Default :: Color
- data AxisEnv = AxisEnv {}
- type LabelFormatter = AxisEnv -> Int -> Double -> Text
- data Bins = Bins {}
- bins :: Int -> Double -> Double -> Bins
- series :: Text -> [(Double, Double)] -> (Text, [(Double, Double)])
- scatter :: [(Text, [(Double, Double)])] -> Plot -> Text
- lineGraph :: [(Text, [(Double, Double)])] -> Plot -> Text
- bars :: [(Text, Double)] -> Plot -> Text
- stackedBars :: [(Text, [(Text, Double)])] -> Plot -> Text
- histogram :: Bins -> [Double] -> Plot -> Text
- pie :: [(Text, Double)] -> Plot -> Text
- heatmap :: [[Double]] -> Plot -> Text
- boxPlot :: [(Text, [Double])] -> Plot -> Text
- area :: [(Text, [(Double, Double)])] -> Plot -> Text
- ribbon :: [(Text, [(Double, Double, Double)])] -> Plot -> Text
- density :: [(Text, [Double])] -> Plot -> Text
- errorBars :: [(Text, [(Double, Double, Double, Double)])] -> Plot -> Text
- funnel :: [(Text, Double)] -> Plot -> Text
- polarLine :: [(Text, [(Double, Double)])] -> Plot -> Text
- waterfall :: [(Text, Double, Double)] -> Plot -> Text
- distPlot :: [(Text, [Double])] -> Plot -> Text
- gauss :: [Double] -> [(Text, Double)] -> Plot -> Text
Documentation
Plot configuration parameters.
Controls the appearance and layout of generated charts.
Constructors
| Plot | |
Fields
| |
Default plot configuration.
Creates a 60×20 character plot with reasonable defaults:
defPlot = Plot
{ widthChars = 60
, heightChars = 20
, leftMargin = 6
, bottomMargin = 2
, titleMargin = 1
, xBounds = (Nothing, Nothing)
, yBounds = (Nothing, Nothing)
, plotTitle = ""
, legendPos = LegendRight
, colorPalette = [ BrightBlue, BrightMagenta, BrightCyan, BrightGreen, BrightYellow, BrightRed, BrightWhite, BrightBlack]
, xFormatter = \ _ _ v -> show v
, yFormatter = \ _ _ v -> show v
, xNumTicks = 2
, yNumTicks = 2
}
Position of the legend in the plot.
Constructors
| LegendRight | Display legend on the right side of the plot |
| LegendBottom | Display legend below the plot |
| LegendNone | Do not display legend. |
A 24-bit RGB colour.
Bundled Patterns
| pattern Black :: Color | |
| pattern Red :: Color | |
| pattern Green :: Color | |
| pattern Yellow :: Color | |
| pattern Blue :: Color | |
| pattern Magenta :: Color | |
| pattern Cyan :: Color | |
| pattern White :: Color | |
| pattern BrightBlack :: Color | |
| pattern BrightRed :: Color | |
| pattern BrightGreen :: Color | |
| pattern BrightYellow :: Color | |
| pattern BrightBlue :: Color | |
| pattern BrightMagenta :: Color | |
| pattern BrightCyan :: Color | |
| pattern BrightWhite :: Color | |
| pattern Default :: Color |
What the formatter gets to know about the axis/ticks
type LabelFormatter Source #
Arguments
| = AxisEnv | Axis context (domain, tick index/count, etc) |
| -> Int | Slot width budget in characters for this tick. |
| -> Double | Raw data value for the tick |
| -> Text | Rendered label (if it doesn't fit in the slot it will be truncated) |
Axis-aware, width-limited, tick-label formatter.
Given:
- axis context
- a per-tick width budget (in terminal cells)
- and the raw tick value.
returns the label to render.
Defines the binning parameters.
bins :: Int -> Double -> Double -> Bins Source #
Create a bin configuration for histograms.
bins 10 0 100 -- 10 bins from 0 to 100 bins 20 (-5) 5 -- 20 bins from -5 to 5
Arguments
| :: Text | Name of the series (appears in legend) |
| -> [(Double, Double)] | List of (x, y) data points |
| -> (Text, [(Double, Double)]) |
Create a named data series for multi-series plots.
let s1 = series "Dataset A" [(1,2), (2,4), (3,6)]
s2 = series "Dataset B" [(1,3), (2,5), (3,7)]
chart = scatter [s1, s2] defPlot
Arguments
| :: [Double] | Population sample (used to compute μ and σ) |
| -> [(Text, Double)] | Named markers as |
| -> Plot | |
| -> Text |
Gaussian / normal-distribution chart in standard-deviation (z-score) units.
Mirrors gauss: a KDE bell curve with a stippled scatter fill, an
x-axis labelled in σ units, and lollipop annotations for named markers
(the largest z highlighted as the outlier).