| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Graphics.Plotly.Base
Description
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 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.
Constructors
| 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
| ToJSON Color # | |
Defined in Graphics.Plotly.Base | |
catColors :: Eq a => [a] -> ListOrElem Value #
Assign colors based on any categorical value
Different types of markers
data ListOrElem a #
Instances
| Eq a => Eq (ListOrElem a) # | |
Defined in Graphics.Plotly.Base | |
| ToJSON a => ToJSON (ListOrElem a) # | |
Defined in Graphics.Plotly.Base Methods toJSON :: ListOrElem a -> Value # toEncoding :: ListOrElem a -> Encoding # toJSONList :: [ListOrElem a] -> Value # toEncodingList :: [ListOrElem a] -> Encoding # | |
Marker specification
Constructors
| Marker | |
Fields
| |
Instances
| Eq Marker # | |
| Generic Marker # | |
| ToJSON Marker # | |
Defined in Graphics.Plotly.Base | |
| type Rep Marker # | |
Defined in Graphics.Plotly.Base type Rep Marker = D1 (MetaData "Marker" "Graphics.Plotly.Base" "plotlyhs-0.2-GQw4xwBsKHSB8ZQAQEkWIM" False) (C1 (MetaCons "Marker" PrefixI True) ((S1 (MetaSel (Just "_size") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (ListOrElem Value))) :*: S1 (MetaSel (Just "_markercolor") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (ListOrElem Value)))) :*: (S1 (MetaSel (Just "_symbol") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Symbol)) :*: S1 (MetaSel (Just "_opacity") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Double))))) | |
markercolor :: Lens' Marker (Maybe (ListOrElem Value)) #
data Orientation #
Horizontal or Vertical orientation of bars
Constructors
| Horizontal | |
| Vertical |
Instances
| ToJSON Orientation # | |
Defined in Graphics.Plotly.Base Methods 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
Constructors
| Line | |
Fields
| |
Instances
| Generic Line # | |
| ToJSON Line # | |
Defined in Graphics.Plotly.Base | |
| type Rep Line # | |
Defined in Graphics.Plotly.Base type Rep Line = D1 (MetaData "Line" "Graphics.Plotly.Base" "plotlyhs-0.2-GQw4xwBsKHSB8ZQAQEkWIM" 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 "_dash") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Dash))))) | |
A Trace is the component of a plot. Multiple traces can be superimposed.
Constructors
| Trace | |
Fields
| |
Instances
orientation :: Lens' Trace (Maybe Orientation) #
Options for axes
Constructors
| Axis | |
Instances
| Generic Axis # | |
| ToJSON Axis # | |
Defined in Graphics.Plotly.Base | |
| type Rep Axis # | |
Defined in Graphics.Plotly.Base type Rep Axis = D1 (MetaData "Axis" "Graphics.Plotly.Base" "plotlyhs-0.2-GQw4xwBsKHSB8ZQAQEkWIM" False) (C1 (MetaCons "Axis" PrefixI True) ((S1 (MetaSel (Just "_range") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (Double, Double))) :*: S1 (MetaSel (Just "_axistitle") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Text))) :*: (S1 (MetaSel (Just "_showgrid") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Bool)) :*: S1 (MetaSel (Just "_zeroline") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Bool))))) | |
Layouts
How different bar traces be superimposed? By grouping or by stacking?
Options for Margins.
Constructors
| Margin | |
Instances
| Generic Margin # | |
| ToJSON Margin # | |
Defined in Graphics.Plotly.Base | |
| type Rep Margin # | |
Defined in Graphics.Plotly.Base type Rep Margin = D1 (MetaData "Margin" "Graphics.Plotly.Base" "plotlyhs-0.2-GQw4xwBsKHSB8ZQAQEkWIM" 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 #
some good values for margins
titleMargins :: Margin #
some good values for margins
options for the layout of the whole plot
Constructors
| Layout | |
Instances
Plotly
A helper record which represents the whole plot