hanalyze-plot: Static-plot integration for hanalyze (toPlot / Plottable)

[ bsd3, library, machine-learning, math, numeric, statistics ] [ Propose Tags ] [ Report a vulnerability ]

The integration layer between hanalyze and the sibling hgg project. It provides the Plottable class, whose toPlot turns a fitted analysis model into an hgg VisualSpec that can be layered with other marks and rendered to static SVG PDF PNG. Instances cover the linear family (LM GLM weighted LM), Bayesian and HBM results (chains, forest plots, posterior predictive checks, model DAGs), robust and quantile regression, smoothing and kernel methods, and the generic fit wrappers. . Unlike the other layers this package sits above the umbrella package hanalyze (the reverse direction would close a package cycle) and depends on the sibling hgg packages, so it is built through the dedicated build root cabal.project.plot rather than the default cabal.project. For Vega-Lite figures and HTML reports see hanalyze-viz instead. See README.md for the module map and a usage example.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.2.0.1
Dependencies ad (>=4.4 && <4.6), aeson (>=2.0 && <2.3), array (>=0.5 && <0.6), async (>=2.2 && <2.3), base (>=4.14 && <5), bytestring (>=0.11 && <0.13), cassava (>=0.5 && <0.6), containers (>=0.6 && <0.8), dataframe-core (>=1.1 && <1.2), dataframe-csv (>=1.0.2 && <1.1), dataframe-json (>=1.0 && <1.1), dataframe-operations (>=1.1.1 && <1.2), dataframe-parquet (>=1.1 && <1.2), deepseq (>=1.4 && <1.6), directory (>=1.3 && <1.4), filepath (>=1.4 && <1.6), hanalyze (==0.2.0.1), hgg-3d (>=0.2 && <0.3), hgg-core (>=0.2 && <0.3), hgg-custom (>=0.2 && <0.3), hgg-svg (>=0.2 && <0.3), hmatrix (>=0.20 && <0.22), hvega (>=0.12 && <0.13), massiv (>=1.0 && <1.1), megaparsec (>=9.0 && <9.7), mwc-random (>=0.15 && <0.16), parallel (>=3.2 && <3.3), parser-combinators (>=1.3 && <1.4), primitive (>=0.7 && <0.10), process (>=1.6 && <1.8), reflection (>=2.1 && <2.2), regex-base (>=0.94 && <0.95), regex-tdfa (>=1.3 && <1.4), statistics (>=0.16 && <0.17), temporary (>=1.3 && <1.4), text (>=1.2 && <2.2), unicode-transforms (>=0.4 && <0.5), unordered-containers (>=0.2 && <0.3), vector (>=0.12 && <0.14), vector-algorithms (>=0.9 && <0.10) [details]
Tested with ghc ==9.6.7
License BSD-3-Clause
Copyright 2026 Aelysce Project (Toshiaki Honda)
Author Toshiaki Honda
Maintainer frenzieddoll@gmail.com
Uploaded by frenzieddoll at 2026-08-13T06:06:32Z
Category Math, Statistics, Numeric, Machine Learning
Distributions
Downloads 0 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-08-13 [all 1 reports]

Readme for hanalyze-plot-0.2.0.1

[back to package description]

hanalyze-plot

The integration layer between hanalyze and the sibling project hgg. Its 8 modules provide toPlot / Plottable, which turn a fitted analysis model into an hgg VisualSpec.

Its dependencies differ from the other layers in two ways:

  • It sits above the umbrella package hanalyze (it imports Fit and Wrappers). Pointing the dependency the other way — umbrella → plot — would create a package cycle, and the cabal file says so explicitly.
  • It depends on hgg-{core,svg,3d,custom} from a sibling repo, so it is not part of the default cabal.project. Build it through the dedicated build root cabal.project.plot:
cabal build --project-file=cabal.project.plot hanalyze-plot
cabal test  --project-file=cabal.project.plot hanalyze-plot-test

If you want Vega-Lite figures and HTML reports, use hanalyze-viz instead. This package targets static SVG / PDF / PNG rendering.

Main modules (all 8)

Module Role
Hanalyze.Plot Entry point of the integration layer; re-exports the instances below together with the Fit API (|->, lm, glm, …)
Plot.Core Model-family-agnostic skeleton — Plottable / SingleVarModel / MultiVarModel and the grid evaluation core
Plot.Linear Instances for the linear family (LMModel, GLMModel, WeightedLMModel, …)
Plot.Bayes Instances for the Bayesian / HBM family (ChainModel, ForestSpec, PPCSpec, DagSpec, GLMMResultRE) plus extractors
Plot.ML Instances and extractors for the ML / statistical model family
Plot.Robust Instances for robust and quantile regression
Plot.Smooth Instances for smoothing and kernel methods
Plot.Wrappers Instances for the generic wrapper types (MultiFit, RegModel)

There is exactly one core type class, in Plot.Core:

class Plottable m where
  -- | The one representative figure (composable with other layers via <>).
  toPlot          :: m -> VisualSpec

  -- | A bundle of diagnostic figures (for reports); defaults to just toPlot.
  diagnosticPlots :: m -> [VisualSpec]
  diagnosticPlots m = [toPlot m]

Support for a new model type is therefore a single instance away.

Usage

build-depends: hanalyze-plot
{-# LANGUAGE OverloadedStrings #-}
import Graphics.Hgg.Frame       ((|>>))
import Graphics.Hgg.Spec        (layer, scatter)
import Graphics.Hgg.Backend.SVG (saveSVGBound)
import Hanalyze.Plot     (toPlot, statModel, grid, (|->), lm)

main :: IO ()
main = do
  let m       = df |-> lm "x" "y"
      lmPlot  = df |>> (layer (scatter "x" "y") <> toPlot m)
  saveSVGBound "lm-scatter-ci.svg" lmPlot

The flow is a single line: df |-> lm "x" "y" (fit) → toPlot (figure) → |>> to overlay it on other layers. Before handing a model to toPlot you can compose rendering options onto it, e.g. statModel m <> grid 200 (grid resolution, band type via bandMode / piMethod, colour via statColor, …).

This is the exact path used by the plot-integration-demo executable (hanalyze-demos/demo-plot/PlotIntegrationDemo.hs), which walks through LM, GLM, spline, GP and quantile regression examples:

cabal run --project-file=cabal.project.demos plot-integration-demo

Tests

The hanalyze-plot-test suite (test-plot/Spec.hs) checks the structure and numerics of toPlot output per model type. It used to live in the umbrella package and was moved here in Phase 106.4, because an umbrella component depending on this package would close a cycle.

repository README