plots-0.1.0.2: Diagrams based plotting library.

Copyright(C) 2015 Christopher Chalmers
LicenseBSD-style (see the file LICENSE)
MaintainerChristopher Chalmers
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Plots.Types.Scatter

Contents

Description

A scatter plot is a type of mathematical diagram using Cartesian coordinates to display values for typically two variables for a set of data.

Synopsis

Scatter plot

data ScatterPlot v n Source #

A general data type for scatter plots. Allows storing different types of data as well as allowing transforms depending on the data.

Scatter plot lenses

data ScatterOptions v n a Source #

A general data type for scatter plots. Allows storing different types of data as well as allowing transforms depending on the data.

Instances

class HasScatterOptions f a d where Source #

Minimal complete definition

gscatterOptions

Methods

gscatterOptions :: LensLike' f a (ScatterOptions (V a) (N a) d) Source #

Lens onto the ScatterOptions for a general scatter plot.

scatterTransform :: Functor f => LensLike' f a (d -> Transformation (V a) (N a)) Source #

Apply a transform to the markers using the associated data.

scatterStyle :: Functor f => LensLike' f a (d -> Style (V a) (N a)) Source #

Apply a style to the markers using the associated data.

scatterPosition :: Functor f => LensLike' f a (d -> Point (V a) (N a)) Source #

Change the position of the markers depending on the data.

Instances

(Functor f, HasScatterOptions f p a) => HasScatterOptions f (Plot p b) a Source # 

Methods

gscatterOptions :: LensLike' f (Plot p b) (ScatterOptions (V (Plot p b)) (N (Plot p b)) a) Source #

scatterTransform :: LensLike' f (Plot p b) (a -> Transformation (V (Plot p b)) (N (Plot p b))) Source #

scatterStyle :: LensLike' f (Plot p b) (a -> Style (V (Plot p b)) (N (Plot p b))) Source #

scatterPosition :: LensLike' f (Plot p b) (a -> Point (V (Plot p b)) (N (Plot p b))) Source #

(Applicative f, Typeable (* -> *) v, Typeable * n, Typeable * d) => HasScatterOptions f (ScatterPlot v n) d Source # 
(Applicative f, Typeable * b, Typeable (* -> *) (BaseSpace c), Typeable * n, Typeable * a) => HasScatterOptions f (Axis b c n) a Source # 

Methods

gscatterOptions :: LensLike' f (Axis b c n) (ScatterOptions (V (Axis b c n)) (N (Axis b c n)) a) Source #

scatterTransform :: LensLike' f (Axis b c n) (a -> Transformation (V (Axis b c n)) (N (Axis b c n))) Source #

scatterStyle :: LensLike' f (Axis b c n) (a -> Style (V (Axis b c n)) (N (Axis b c n))) Source #

scatterPosition :: LensLike' f (Axis b c n) (a -> Point (V (Axis b c n)) (N (Axis b c n))) Source #

(Applicative f, Typeable * b, Typeable (* -> *) v, Typeable * n, Typeable * a) => HasScatterOptions f (DynamicPlot b v n) a Source # 

Methods

gscatterOptions :: LensLike' f (DynamicPlot b v n) (ScatterOptions (V (DynamicPlot b v n)) (N (DynamicPlot b v n)) a) Source #

scatterTransform :: LensLike' f (DynamicPlot b v n) (a -> Transformation (V (DynamicPlot b v n)) (N (DynamicPlot b v n))) Source #

scatterStyle :: LensLike' f (DynamicPlot b v n) (a -> Style (V (DynamicPlot b v n)) (N (DynamicPlot b v n))) Source #

scatterPosition :: LensLike' f (DynamicPlot b v n) (a -> Point (V (DynamicPlot b v n)) (N (DynamicPlot b v n))) Source #

(~) * d d' => HasScatterOptions f (ScatterOptions v n d) d' Source # 

class HasConnectingLine f a where Source #

Class of things that have a LensLike for a ScatterPlot 's connecting line.

Minimal complete definition

connectingLine

Methods

connectingLine :: Functor f => LensLike' f a Bool Source #

LensLike onto whether the scatter plot should have a connecting line between points. If the line is present, it uses the lineStyle from the PlotStyle.

Basic scatter plot

Add plots to the axis

scatterPlot Source #

Arguments

:: (BaseSpace c ~ v, PointLike v n p, Typeable n, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b, Foldable f) 
=> f p

points to plot

-> State (Plot (ScatterOptions v n (Point v n)) b) ()

changes to plot options

-> m ()

add plot to Axis

Add a ScatterPlot to the AxisState from a data set.

  myaxis = r2Axis ~&
    scatterPlot data1

Example

import Plots
mydata1 = [(1,3), (2,5.5), (3.2, 6), (3.5, 6.1)]
mydata2 = mydata1 & each . _1 *~ 0.5
mydata3 = [V2 1.2 2.7, V2 2 5.1, V2 3.2 2.6, V2 3.5 5]
scatterAxis :: Axis B V2 Double
scatterAxis = r2Axis &~ do
  scatterPlot mydata1 $ key "data 1"
  scatterPlot mydata2 $ key "data 2"
  scatterPlot mydata3 $ key "data 3"
scatterExample = renderAxis scatterAxis

scatterPlot' Source #

Arguments

:: (BaseSpace c ~ v, PointLike v n p, Typeable n, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b, Foldable f) 
=> f p

points to plot

-> m ()

add plot to Axis

Version of scatterPlot without any changes to the ScatterOptions.

Example

import Plots
mydata4 = [(1,3), (2,5.5), (3.2, 6), (3.5, 6.1)]
mydata5 = mydata1 & each . _1 *~ 0.5
mydata6 = [V2 1.2 2.7, V2 2 5.1, V2 3.2 2.6, V2 3.5 5]
scatterAxis' :: Axis B V2 Double
scatterAxis' = r2Axis &~ do
  scatterPlot' mydata4
  scatterPlot' mydata5
  scatterPlot' mydata6
scatterExample' = renderAxis scatterAxis'

scatterPlotOf Source #

Arguments

:: (BaseSpace c ~ v, PointLike v n p, Typeable n, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b) 
=> Fold s p

fold over points

-> s

data to fold

-> State (Plot (ScatterOptions v n (Point v n)) b) ()

changes to plot options

-> m ()

add plot to Axis

Version of scatterPlot that accepts a Fold over the data.

scatterPlotOf' Source #

Arguments

:: (BaseSpace c ~ v, PointLike v n p, Typeable n, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b) 
=> Fold s p

fold over points

-> s

data to fold

-> m ()

add plot to axis

Version of scatterPlot that accepts a Fold over the data without any changes to the ScatterOptions.

Scatter options

scatterOptions :: (InSpace v n a, HasScatterOptions f a (Point v n)) => LensLike' f a (ScatterOptions v n (Point v n)) Source #

Lens onto a scatter plot of points.

Bubble plots

bubblePlot Source #

Arguments

:: (BaseSpace c ~ v, PointLike v n p, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b, Typeable n, Foldable f) 
=> f (n, p)

fold over points with a size

-> State (Plot (BubbleOptions v n) b) ()

changes to the options

-> m ()

add plot to Axis

Scatter plots with extra numeric parameter. By default the extra parameter is the scale of the marker but this can be changed.

bubblePlot' Source #

Arguments

:: (v ~ BaseSpace c, PointLike v n p, Typeable n, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b, Foldable f) 
=> f (n, p)

fold over points with a size

-> m ()

add plot to Axis

Simple version of bubblePlot without any changes to the Plot.

bubblePlotOf Source #

Arguments

:: (BaseSpace c ~ v, PointLike v n p, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b, Typeable n) 
=> Fold s (n, p)

fold over the data

-> s

data

-> State (Plot (BubbleOptions v n) b) ()

changes to the options

-> m ()

add plot to Axis

Version of bubblePlot using a Fold over the data.

bubblePlotOf' Source #

Arguments

:: (BaseSpace c ~ v, PointLike v n p, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b, Typeable n) 
=> Fold s (n, p)

fold over the data

-> s

data

-> State (Plot (BubbleOptions v n) b) ()

changes to the options

-> m ()

add plot to Axis

Version of bubblePlot using a Fold over the data without any changes to the BubbleOptions.

Bubble options

type BubbleOptions v n = ScatterOptions v n (n, Point v n) Source #

A bubble plot is a scatter plot using point together with a scalar.

bubbleOptions :: (InSpace v n a, HasScatterOptions f a (n, Point v n)) => LensLike' f a (BubbleOptions v n) Source #

LensLike onto into a ScatterOptions made up of a scaler n, and a point, Point v n

bubbleOptions :: Lens' (Plot (BubbleOptions v n) v) (BubbleOptions v n)

bubbleTransform :: (InSpace v n a, HasScatterOptions f a (n, Point v n), Settable f) => LensLike' f a (n -> Transformation v n) Source #

Setter over the transform function for a bubblePlot. Default is scale.

bubbleOptions :: Setter' (Plot (BubbleOptions v n) v) (n -> Transformation v n)

Note that this is the less general version of bubblePlot . scatterTransform, which would give a LensLike onto (n, Point v n) -> Transformation v n.

bubbleStyle :: (InSpace v n a, Settable f, HasScatterOptions f a (n, Point v n)) => LensLike' f a (n -> Style v n) Source #

Setter over the style function for a bubblePlot. Default is mempty.

bubbleStyle :: Setter' (Plot (BubbleOptions v n) v) (n -> Style v n)

Note that this is the less general version of bubblePlot . scatterTransform, which would give a LensLike onto (n, Point v n) -> Style v n.

General scatter plot

gscatterPlot Source #

Arguments

:: (BaseSpace c ~ v, PointLike v n p, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b, Typeable d, Foldable f) 
=> f d

data

-> (d -> p)

extract point from data

-> State (Plot (ScatterOptions v n d) b) ()

options for plot

-> m ()

add plot to Axis

A general scatter plot allow using any data type d to determine the scatterTransform and scatterStyle.

gscatterOptionsFor :: (InSpace v n a, HasScatterOptions f a d) => proxy d -> LensLike' f a (ScatterOptions v n d) Source #

Helper to traverse over a general scatter plot where the type of d is not infered.

Low level construction

mkScatterOptions :: (PointLike v n p, Foldable f, Fractional n) => f a -> (a -> p) -> ScatterOptions v n a Source #

Low level construction of ScatterOptions.