Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module defines datatypes that can be used to generate Plotly.js
plots via their JSON values. The interface encourages the use of
lenses. Every trace on a plot is defined by a Trace
type value, the
construction of which is the central goal of this module.
Example scatter plot of the Iris dataset:
import Graphics.Plotly import Numeric.Dataset.Iris tr :: Trace tr = scatter & x ?~ map sepalLength iris & y ?~ map sepalWidth iris & marker ?~ (defMarker & markercolor ?~ catColors (map irisClass irisd)) & mode ?~ [Markers]
Horizontal bars:
hbarData :: [(Text, Double)] hbarData = [("Simon", 14.5), ("Joe", 18.9), ("Dorothy", 16.2)] hbarsTrace :: Trace hbarsTrace = bars & ytext ?~ map fst hbarData & x ?~ map snd hbarData & orientation ?~ Horizontal
see Graphics.Plotly.Lucid for helper functions that turn traces into HTML.
- data Mode
- data TraceType
- data Color
- catColors :: Eq a => [a] -> ListOrElem Value
- data Symbol
- data ListOrElem a
- data Marker = Marker {
- _size :: Maybe (ListOrElem Value)
- _markercolor :: Maybe (ListOrElem Value)
- _symbol :: Maybe Symbol
- _opacity :: Maybe Double
- symbol :: Lens' Marker (Maybe Symbol)
- size :: Lens' Marker (Maybe (ListOrElem Value))
- opacity :: Lens' Marker (Maybe Double)
- markercolor :: Lens' Marker (Maybe (ListOrElem Value))
- defMarker :: Marker
- data Dash
- data Orientation
- data Fill
- data Line = Line {
- _linewidth :: Maybe Double
- _linecolor :: Maybe Color
- _dash :: Maybe Dash
- linewidth :: Lens' Line (Maybe Double)
- linecolor :: Lens' Line (Maybe Color)
- dash :: Lens' Line (Maybe Dash)
- defLine :: Line
- data Trace = Trace {}
- y :: Lens' Trace (Maybe [Value])
- x :: Lens' Trace (Maybe [Value])
- tracetype :: Lens' Trace TraceType
- text :: Lens' Trace (Maybe [Text])
- orientation :: Lens' Trace (Maybe Orientation)
- name :: Lens' Trace (Maybe Text)
- mode :: Lens' Trace (Maybe [Mode])
- marker :: Lens' Trace (Maybe Marker)
- line :: Lens' Trace (Maybe Line)
- fill :: Lens' Trace (Maybe Fill)
- scatter :: Trace
- bars :: Trace
- data Axis = Axis {}
- zeroline :: Lens' Axis (Maybe Bool)
- showgrid :: Lens' Axis (Maybe Bool)
- range :: Lens' Axis (Maybe (Double, Double))
- axistitle :: Lens' Axis (Maybe Text)
- defAxis :: Axis
- data Barmode
- data Margin = Margin {}
- margint :: Lens' Margin Int
- marginr :: Lens' Margin Int
- marginpad :: Lens' Margin Int
- marginl :: Lens' Margin Int
- marginb :: Lens' Margin Int
- thinMargins :: Margin
- titleMargins :: Margin
- data Layout = Layout {}
- yaxis :: Lens' Layout (Maybe Axis)
- xaxis :: Lens' Layout (Maybe Axis)
- width :: Lens' Layout (Maybe Int)
- title :: Lens' Layout (Maybe Text)
- showlegend :: Lens' Layout (Maybe Bool)
- margin :: Lens' Layout (Maybe Margin)
- height :: Lens' Layout (Maybe Int)
- barmode :: Lens' Layout (Maybe Barmode)
- defLayout :: Layout
- data Plotly = Plotly {}
- traces :: Lens' Plotly [Trace]
- layout :: Lens' Plotly Layout
- elemid :: Lens' Plotly Text
- plotly :: Text -> [Trace] -> Plotly
Traces
How should traces be drawn? (lines or markers)
What kind of plot type are we building - scatter (inluding line plots) or bars?
A color specification, either as a concrete RGB/RGBA value or a color per point.
Different types of markers
data ListOrElem a Source #
Eq a => Eq (ListOrElem a) Source # | |
ToJSON a => ToJSON (ListOrElem a) Source # | |
Marker specification
Marker | |
|
markercolor :: Lens' Marker (Maybe (ListOrElem Value)) Source #
data Orientation Source #
Horizontal or Vertical orientation of bars
Are we filling area plots from the zero line or to the next Y value?
line specification
Line | |
|
A Trace
is the component of a plot. Multiple traces can be superimposed.
Trace | |
|
orientation :: Lens' Trace (Maybe Orientation) Source #
Options for axes
Layouts
How different bar traces be superimposed? By grouping or by stacking?
Options for Margins.
thinMargins :: Margin Source #
some good values for margins
titleMargins :: Margin Source #
some good values for margins
options for the layout of the whole plot
Plotly
A helper record which represents the whole plot