Safe Haskell | Safe-Inferred |
---|---|
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.
Synopsis
- data Mode
- data TraceType
- data Color
- catColors :: Eq a => [a] -> ListOrElem Value
- data Symbol
- data ListOrElem a
- data Sizemode
- data MarkerLine = MarkerLine {}
- markerlinewidth :: Lens' MarkerLine (Maybe (ListOrElem Double))
- markerlinecolor :: Lens' MarkerLine (Maybe (ListOrElem Value))
- defMarkerLine :: MarkerLine
- data Marker = Marker {
- _size :: Maybe (ListOrElem Value)
- _sizeref :: Maybe Value
- _sizeMode :: Maybe Sizemode
- _markercolor :: Maybe (ListOrElem Value)
- _markercolors :: Maybe (ListOrElem Value)
- _symbol :: Maybe (ListOrElem Symbol)
- _opacity :: Maybe Double
- _markerline :: Maybe MarkerLine
- symbol :: Lens' Marker (Maybe (ListOrElem Symbol))
- sizeref :: Lens' Marker (Maybe Value)
- sizeMode :: Lens' Marker (Maybe Sizemode)
- size :: Lens' Marker (Maybe (ListOrElem Value))
- opacity :: Lens' Marker (Maybe Double)
- markerline :: Lens' Marker (Maybe MarkerLine)
- markercolors :: Lens' Marker (Maybe (ListOrElem Value))
- markercolor :: Lens' Marker (Maybe (ListOrElem Value))
- defMarker :: Marker
- data Dash
- data Orientation
- data Fill
- data LineShape
- data Line = Line {
- _linewidth :: Maybe Double
- _linecolor :: Maybe Color
- _lineshape :: Maybe LineShape
- _dash :: Maybe Dash
- linewidth :: Lens' Line (Maybe Double)
- lineshape :: Lens' Line (Maybe LineShape)
- linecolor :: Lens' Line (Maybe Color)
- dash :: Lens' Line (Maybe Dash)
- defLine :: Line
- data HoverElem
- data HoverInfo
- data HoverMode
- data HoverOn
- data TextPosition
- data Trace = Trace {
- _x :: Maybe [Value]
- _y :: Maybe [Value]
- _z :: Maybe [Value]
- _values :: Maybe [Value]
- _labels :: Maybe [Text]
- _hole :: Maybe Value
- _mode :: Maybe [Mode]
- _name :: Maybe Text
- _text :: Maybe [Text]
- _textposition :: Maybe TextPosition
- _tracetype :: TraceType
- _marker :: Maybe Marker
- _line :: Maybe Line
- _fill :: Maybe Fill
- _orientation :: Maybe Orientation
- _visible :: Maybe Value
- _traceshowlegend :: Maybe Bool
- _legendgroup :: Maybe Text
- _customdata :: Maybe [Value]
- _hoverinfo :: Maybe HoverInfo
- _hovertext :: Maybe (ListOrElem Text)
- _hoveron :: Maybe [HoverOn]
- _connectgaps :: Maybe Bool
- _stackgroup :: Maybe Text
- _fillcolor :: Maybe Text
- _sort :: Maybe Bool
- _i :: Maybe [Int]
- _j :: Maybe [Int]
- _k :: Maybe [Int]
- _tracecolor :: Maybe Color
- _traceopacity :: Maybe Double
- _tracexaxis :: Maybe Text
- _traceyaxis :: Maybe Text
- z :: Lens' Trace (Maybe [Value])
- y :: Lens' Trace (Maybe [Value])
- x :: Lens' Trace (Maybe [Value])
- visible :: Lens' Trace (Maybe Value)
- values :: Lens' Trace (Maybe [Value])
- traceyaxis :: Lens' Trace (Maybe Text)
- tracexaxis :: Lens' Trace (Maybe Text)
- tracetype :: Lens' Trace TraceType
- traceshowlegend :: Lens' Trace (Maybe Bool)
- traceopacity :: Lens' Trace (Maybe Double)
- tracecolor :: Lens' Trace (Maybe Color)
- textposition :: Lens' Trace (Maybe TextPosition)
- text :: Lens' Trace (Maybe [Text])
- stackgroup :: Lens' Trace (Maybe Text)
- sort :: Lens' Trace (Maybe Bool)
- 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)
- legendgroup :: Lens' Trace (Maybe Text)
- labels :: Lens' Trace (Maybe [Text])
- k :: Lens' Trace (Maybe [Int])
- j :: Lens' Trace (Maybe [Int])
- i :: Lens' Trace (Maybe [Int])
- hovertext :: Lens' Trace (Maybe (ListOrElem Text))
- hoveron :: Lens' Trace (Maybe [HoverOn])
- hoverinfo :: Lens' Trace (Maybe HoverInfo)
- hole :: Lens' Trace (Maybe Value)
- fillcolor :: Lens' Trace (Maybe Text)
- fill :: Lens' Trace (Maybe Fill)
- customdata :: Lens' Trace (Maybe [Value])
- connectgaps :: Lens' Trace (Maybe Bool)
- mkTrace :: TraceType -> Trace
- scatter :: Trace
- scatter3d :: Trace
- bars :: Trace
- box :: Trace
- mesh3d :: Trace
- contour :: Trace
- pie :: Trace
- data AxisType
- data Axis = Axis {}
- zeroline :: Lens' Axis (Maybe Bool)
- tickvals :: Lens' Axis (Maybe [Value])
- ticktext :: Lens' Axis (Maybe [Text])
- showgrid :: Lens' Axis (Maybe Bool)
- range :: Lens' Axis (Maybe (Double, Double))
- domain :: Lens' Axis (Maybe (Double, Double))
- axisvisible :: Lens' Axis (Maybe Bool)
- axistype :: Lens' Axis (Maybe AxisType)
- 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 Font = Font {
- _fontfamily :: Maybe Text
- _fontsize :: Maybe Double
- _fontcolor :: Maybe Color
- fontsize :: Lens' Font (Maybe Double)
- fontfamily :: Lens' Font (Maybe Text)
- fontcolor :: Lens' Font (Maybe Color)
- defFont :: Font
- data Align
- data Annotation = Annotation {
- _annotationvisible :: Maybe Bool
- _annotationtext :: Maybe Text
- _annotationfont :: Maybe Font
- _annotationwidth :: Maybe Double
- _annotationheight :: Maybe Double
- _annotationopacity :: Maybe Double
- _annotationalign :: Maybe Align
- _annotataonbgcolor :: Maybe Color
- _annotationbordercolor :: Maybe Color
- _annotationshowarrow :: Maybe Bool
- _annotationx :: Maybe Value
- _annotationxref :: Maybe Text
- _annotationxshift :: Maybe Double
- _annotationy :: Maybe Value
- _annotationyref :: Maybe Text
- _annotationyshift :: Maybe Double
- annotationyshift :: Lens' Annotation (Maybe Double)
- annotationyref :: Lens' Annotation (Maybe Text)
- annotationy :: Lens' Annotation (Maybe Value)
- annotationxshift :: Lens' Annotation (Maybe Double)
- annotationxref :: Lens' Annotation (Maybe Text)
- annotationx :: Lens' Annotation (Maybe Value)
- annotationwidth :: Lens' Annotation (Maybe Double)
- annotationvisible :: Lens' Annotation (Maybe Bool)
- annotationtext :: Lens' Annotation (Maybe Text)
- annotationshowarrow :: Lens' Annotation (Maybe Bool)
- annotationopacity :: Lens' Annotation (Maybe Double)
- annotationheight :: Lens' Annotation (Maybe Double)
- annotationfont :: Lens' Annotation (Maybe Font)
- annotationbordercolor :: Lens' Annotation (Maybe Color)
- annotationalign :: Lens' Annotation (Maybe Align)
- annotataonbgcolor :: Lens' Annotation (Maybe Color)
- defAnnotation :: Annotation
- data Layout = Layout {
- _xaxis :: Maybe Axis
- _xaxis2 :: Maybe Axis
- _xaxis3 :: Maybe Axis
- _xaxis4 :: Maybe Axis
- _yaxis :: Maybe Axis
- _yaxis2 :: Maybe Axis
- _yaxis3 :: Maybe Axis
- _yaxis4 :: Maybe Axis
- _zaxis :: Maybe Axis
- _title :: Maybe Text
- _titlefont :: Maybe Font
- _showlegend :: Maybe Bool
- _height :: Maybe Int
- _width :: Maybe Int
- _barmode :: Maybe Barmode
- _hovermode :: Maybe HoverMode
- _margin :: Maybe Margin
- _font :: Maybe Font
- _annotations :: Maybe [Annotation]
- zaxis :: Lens' Layout (Maybe Axis)
- yaxis4 :: Lens' Layout (Maybe Axis)
- yaxis3 :: Lens' Layout (Maybe Axis)
- yaxis2 :: Lens' Layout (Maybe Axis)
- yaxis :: Lens' Layout (Maybe Axis)
- xaxis4 :: Lens' Layout (Maybe Axis)
- xaxis3 :: Lens' Layout (Maybe Axis)
- xaxis2 :: Lens' Layout (Maybe Axis)
- xaxis :: Lens' Layout (Maybe Axis)
- width :: Lens' Layout (Maybe Int)
- titlefont :: Lens' Layout (Maybe Font)
- title :: Lens' Layout (Maybe Text)
- showlegend :: Lens' Layout (Maybe Bool)
- margin :: Lens' Layout (Maybe Margin)
- hovermode :: Lens' Layout (Maybe HoverMode)
- height :: Lens' Layout (Maybe Int)
- font :: Lens' Layout (Maybe Font)
- barmode :: Lens' Layout (Maybe Barmode)
- annotations :: Lens' Layout (Maybe [Annotation])
- 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.
ColRGBA Int Int Int Int | use this RGBA color for every point in the trace |
ColRGB Int Int Int | use this RGB color for every point in the trace |
ColIx Int | use a different color index for each point |
Instances
Different types of markers
data ListOrElem a Source #
Instances
ToJSON a => ToJSON (ListOrElem a) Source # | |
Defined in Graphics.Plotly.Base toJSON :: ListOrElem a -> Value # toEncoding :: ListOrElem a -> Encoding # toJSONList :: [ListOrElem a] -> Value # toEncodingList :: [ListOrElem a] -> Encoding # | |
Eq a => Eq (ListOrElem a) Source # | |
Defined in Graphics.Plotly.Base (==) :: ListOrElem a -> ListOrElem a -> Bool # (/=) :: ListOrElem a -> ListOrElem a -> Bool # |
data MarkerLine Source #
Marker line specification
Instances
defMarkerLine :: MarkerLine Source #
default marker line specification
Marker specification
Marker | |
|
Instances
markerline :: Lens' Marker (Maybe MarkerLine) Source #
markercolors :: Lens' Marker (Maybe (ListOrElem Value)) Source #
markercolor :: Lens' Marker (Maybe (ListOrElem Value)) Source #
Dash type specification
data Orientation Source #
Horizontal or Vertical orientation of bars
Instances
ToJSON Orientation Source # | |
Defined in Graphics.Plotly.Base toJSON :: Orientation -> Value # toEncoding :: Orientation -> Encoding # toJSONList :: [Orientation] -> Value # toEncodingList :: [Orientation] -> Encoding # |
Are we filling area plots from the zero line or to the next Y value?
line specification
Line | |
|
Instances
ToJSON Line Source # | |
Defined in Graphics.Plotly.Base | |
Generic Line Source # | |
type Rep Line Source # | |
Defined in Graphics.Plotly.Base type Rep Line = D1 ('MetaData "Line" "Graphics.Plotly.Base" "plotlyhs-0.2.2-inplace" 'False) (C1 ('MetaCons "Line" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_linewidth") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Double)) :*: S1 ('MetaSel ('Just "_linecolor") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Color))) :*: (S1 ('MetaSel ('Just "_lineshape") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe LineShape)) :*: S1 ('MetaSel ('Just "_dash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Dash))))) |
Instances
Generic HoverElem Source # | |
Show HoverElem Source # | |
type Rep HoverElem Source # | |
Defined in Graphics.Plotly.Base type Rep HoverElem = D1 ('MetaData "HoverElem" "Graphics.Plotly.Base" "plotlyhs-0.2.2-inplace" 'False) ((C1 ('MetaCons "HoverX" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "HoverY" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "HoverZ" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "HoverText" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "HoverName" 'PrefixI 'False) (U1 :: Type -> Type)))) |
Instances
ToJSON HoverInfo Source # | |
Defined in Graphics.Plotly.Base | |
Generic HoverInfo Source # | |
Show HoverInfo Source # | |
type Rep HoverInfo Source # | |
Defined in Graphics.Plotly.Base type Rep HoverInfo = D1 ('MetaData "HoverInfo" "Graphics.Plotly.Base" "plotlyhs-0.2.2-inplace" 'False) ((C1 ('MetaCons "HoverPlus" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [HoverElem])) :+: C1 ('MetaCons "HoverAll" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "HoverNone" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "HoverSkip" 'PrefixI 'False) (U1 :: Type -> Type))) |
data TextPosition Source #
Instances
A Trace
is the component of a plot. Multiple traces can be superimposed.
Instances
orientation :: Lens' Trace (Maybe Orientation) Source #
Options for axes
Instances
Layouts
How different bar traces be superimposed? By grouping or by stacking?
Options for Margins.
Instances
ToJSON Margin Source # | |
Defined in Graphics.Plotly.Base | |
Generic Margin Source # | |
type Rep Margin Source # | |
Defined in Graphics.Plotly.Base type Rep Margin = D1 ('MetaData "Margin" "Graphics.Plotly.Base" "plotlyhs-0.2.2-inplace" 'False) (C1 ('MetaCons "Margin" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_marginl") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "_marginr") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :*: (S1 ('MetaSel ('Just "_marginb") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: (S1 ('MetaSel ('Just "_margint") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "_marginpad") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int))))) |
thinMargins :: Margin Source #
some good values for margins
titleMargins :: Margin Source #
some good values for margins
Options for Fonts.
Font | |
|
Instances
ToJSON Font Source # | |
Defined in Graphics.Plotly.Base | |
Generic Font Source # | |
type Rep Font Source # | |
Defined in Graphics.Plotly.Base type Rep Font = D1 ('MetaData "Font" "Graphics.Plotly.Base" "plotlyhs-0.2.2-inplace" 'False) (C1 ('MetaCons "Font" 'PrefixI 'True) (S1 ('MetaSel ('Just "_fontfamily") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text)) :*: (S1 ('MetaSel ('Just "_fontsize") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Double)) :*: S1 ('MetaSel ('Just "_fontcolor") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Color))))) |
Instances
ToJSON Align Source # | |
Defined in Graphics.Plotly.Base | |
Generic Align Source # | |
Show Align Source # | |
type Rep Align Source # | |
Defined in Graphics.Plotly.Base type Rep Align = D1 ('MetaData "Align" "Graphics.Plotly.Base" "plotlyhs-0.2.2-inplace" 'False) (C1 ('MetaCons "AlignLeft" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "AlignCenter" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "AlignRight" 'PrefixI 'False) (U1 :: Type -> Type))) |
data Annotation Source #
Options for annotations
Annotation | |
|
Instances
annotationy :: Lens' Annotation (Maybe Value) Source #
annotationx :: Lens' Annotation (Maybe Value) Source #
options for the layout of the whole plot
Layout | |
|
Instances
annotations :: Lens' Layout (Maybe [Annotation]) Source #
Plotly
A helper record which represents the whole plot
Instances
ToJSON Plotly Source # | |
Defined in Graphics.Plotly.Base | |
Generic Plotly Source # | |
ToMarkup Plotly Source # | |
Defined in Graphics.Plotly.Blaze | |
ToHtml Plotly Source # | |
type Rep Plotly Source # | |
Defined in Graphics.Plotly.Base type Rep Plotly = D1 ('MetaData "Plotly" "Graphics.Plotly.Base" "plotlyhs-0.2.2-inplace" 'False) (C1 ('MetaCons "Plotly" 'PrefixI 'True) (S1 ('MetaSel ('Just "_elemid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: (S1 ('MetaSel ('Just "_traces") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Trace]) :*: S1 ('MetaSel ('Just "_layout") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Layout)))) |