plotlyhs-0.1.0: Haskell bindings to Plotly.js

Safe HaskellNone
LanguageHaskell98

Graphics.Plotly

Contents

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

Traces

data Mode Source #

How should traces be drawn? (lines or markers)

Constructors

Markers 
Lines 

Instances

data TraceType Source #

What kind of plot type are we building - scatter (inluding line plots) or bars?

Constructors

Scatter 
Bar 

data Color Source #

A color specification, either as a concrete RGB/RGBA value or a color per point.

Constructors

RGBA Int Int Int Int

use this RGBA color for every point in the trace

RGB Int Int Int

use this RGB color for every point in the trace

ColIxs [Int]

use a different color index for each point

Cols [Color]

use a different color for each point

catColors :: Eq a => [a] -> Color Source #

Assign colors based on any categorical value

data Symbol Source #

Different types of markers

Constructors

Circle 
Square 
Diamond 
Cross 

defMarker :: Marker Source #

default marker specification

data Dash Source #

Dash type specification

Constructors

Solid 
Dashdot 
Dot 

data Orientation Source #

Horizontal or Vertical orientation of bars

Constructors

Horizontal 
Vertical 

data Fill Source #

Are we filling area plots from the zero line or to the next Y value?

Constructors

ToZeroY 
ToNextY 

data Line Source #

line specification

Constructors

Line 

Instances

Generic Line Source # 

Associated Types

type Rep Line :: * -> * #

Methods

from :: Line -> Rep Line x #

to :: Rep Line x -> Line #

ToJSON Line Source # 
type Rep Line Source # 

data Trace Source #

A Trace is the component of a plot. Multiple traces can be superimposed.

Constructors

Trace 

Fields

Instances

Generic Trace Source # 

Associated Types

type Rep Trace :: * -> * #

Methods

from :: Trace -> Rep Trace x #

to :: Rep Trace x -> Trace #

ToJSON Trace Source # 
type Rep Trace Source # 
type Rep Trace = D1 (MetaData "Trace" "Graphics.Plotly" "plotlyhs-0.1.0-IhdqYuzSpJ97cW13Y55OXb" False) (C1 (MetaCons "Trace" PrefixI True) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "_x") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe [Double]))) ((:*:) (S1 (MetaSel (Just Symbol "_y") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe [Double]))) (S1 (MetaSel (Just Symbol "_xtext") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe [Text]))))) ((:*:) (S1 (MetaSel (Just Symbol "_ytext") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe [Text]))) ((:*:) (S1 (MetaSel (Just Symbol "_mode") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe [Mode]))) (S1 (MetaSel (Just Symbol "_name") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Text)))))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "_text") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe [Text]))) ((:*:) (S1 (MetaSel (Just Symbol "_tracetype") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 TraceType)) (S1 (MetaSel (Just Symbol "_marker") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Marker))))) ((:*:) (S1 (MetaSel (Just Symbol "_line") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Line))) ((:*:) (S1 (MetaSel (Just Symbol "_fill") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Fill))) (S1 (MetaSel (Just Symbol "_orientation") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Orientation))))))))

scatter :: Trace Source #

an empty scatter plot

bars :: Trace Source #

an empty bar plot

data Axis Source #

Options for axes

Layouts

data Barmode Source #

How different bar traces be superimposed? By grouping or by stacking?

Constructors

Stack 
Group 

thinMargins :: Margin Source #

some good values for margins

titleMargins :: Margin Source #

some good values for margins

data Layout Source #

options for the layout of the whole plot

defLayout :: Layout Source #

a defaultlayout

Plotly

data Plotly Source #

A helper record which represents the whole plot

Constructors

Plotly 

Fields

plotly :: Text -> [Trace] -> Plotly Source #

helper function for building the plot.