HORIZON HASKELLDocslts/ghc-10.0.x2b276322026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 2b27632 · 2026-10-31

Modulegranite-0.7.4.0GHC2021

Granite.Svg

SVG plotting backend that mirrors the API of Granite. Each chart function returns a self-contained SVG document as Text.

Synopsis
datadata Plot

Plot configuration parameters.

Controls the appearance and layout of generated charts.

Constructors

valuedefPlot :: Plot

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
  }
typetype LabelFormatter = AxisEnv -> Int -> Double -> Text

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.

valuebins :: Int -> Double -> Double -> Bins

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
valueseries
  1. :: Text

    Name of the series (appears in legend)

  2. -> [(Double, Double)]

    List of (x, y) data points

  3. -> (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
valuegauss
  1. :: [Double]

    Population sample (used to compute μ and σ)

  2. -> [(Text, Double)]

    Named markers as (label, raw value); the largest z is highlighted

  3. -> Plot
  4. -> 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).