plots-0.1.1.3: Diagrams based plotting library
Copyright(C) 2015 Christopher Chalmers
LicenseBSD-style (see the file LICENSE)
MaintainerChristopher Chalmers
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Plots.Types.Scatter

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.

(see scatterPlot example for code to make this plot)

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.

Instances

Instances details
HasConnectingLine f (ScatterPlot v n) Source # 
Instance details

Defined in Plots.Types.Scatter

(Applicative f, Typeable v, Typeable n, Typeable d) => HasScatterOptions f (ScatterPlot v n) d Source # 
Instance details

Defined in Plots.Types.Scatter

(Metric v, OrderedField n) => Enveloped (ScatterPlot v n) Source # 
Instance details

Defined in Plots.Types.Scatter

Methods

getEnvelope :: ScatterPlot v n -> Envelope (V (ScatterPlot v n)) (N (ScatterPlot v n)) #

(TypeableFloat n, Renderable (Path V2 n) b) => Plotable (ScatterPlot V2 n) b Source # 
Instance details

Defined in Plots.Types.Scatter

Methods

renderPlotable :: forall (v :: Type -> Type) n0. InSpace v n0 (ScatterPlot V2 n) => AxisSpec v n0 -> PlotStyle b v n0 -> ScatterPlot V2 n -> QDiagram b v n0 Any Source #

defLegendPic :: forall (v :: Type -> Type) n0. InSpace v n0 (ScatterPlot V2 n) => PlotStyle b v n0 -> ScatterPlot V2 n -> QDiagram b v n0 Any Source #

type N (ScatterPlot v n) Source # 
Instance details

Defined in Plots.Types.Scatter

type N (ScatterPlot v n) = n
type V (ScatterPlot v n) Source # 
Instance details

Defined in Plots.Types.Scatter

type V (ScatterPlot v n) = v

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

Instances details
HasConnectingLine f (ScatterOptions v n a) Source # 
Instance details

Defined in Plots.Types.Scatter

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

Defined in Plots.Types.Scatter

type N (ScatterOptions v n a) Source # 
Instance details

Defined in Plots.Types.Scatter

type N (ScatterOptions v n a) = n
type V (ScatterOptions v n a) Source # 
Instance details

Defined in Plots.Types.Scatter

type V (ScatterOptions v n a) = v

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

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

Defined in Plots.Types.Scatter

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 # 
Instance details

Defined in Plots.Types.Scatter

(Applicative f, Typeable b, Typeable (BaseSpace c), Typeable n, Typeable a) => HasScatterOptions f (Axis b c n) a Source # 
Instance details

Defined in Plots.Types.Scatter

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 # 
Instance details

Defined in Plots.Types.Scatter

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 # 
Instance details

Defined in Plots.Types.Scatter

class HasConnectingLine f a where Source #

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

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.

Instances

Instances details
HasConnectingLine f p => HasConnectingLine f (Plot p b) Source # 
Instance details

Defined in Plots.Types.Scatter

HasConnectingLine f (ScatterPlot v n) Source # 
Instance details

Defined in Plots.Types.Scatter

(Settable f, Typeable (BaseSpace c), Typeable n) => HasConnectingLine f (Axis b c n) Source # 
Instance details

Defined in Plots.Types.Scatter

(Applicative f, Typeable b, Typeable v, Typeable n) => HasConnectingLine f (DynamicPlot b v n) Source # 
Instance details

Defined in Plots.Types.Scatter

(Applicative f, Typeable v, Typeable n) => HasConnectingLine f (StyledPlot b v n) Source # 
Instance details

Defined in Plots.Types.Scatter

HasConnectingLine f (ScatterOptions v n a) Source # 
Instance details

Defined in Plots.Types.Scatter

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.

scatterPlot :: [(Double, Double)] -> State (Plot (ScatterOptions V2 Double (P2 Double)) b) () -> State (Axis b V2 Double) ()
scatterPlot :: [V2 Double]        -> State (Plot (ScatterOptions V2 Double (P2 Double)) b) () -> State (Axis b V2 Double) ()
scatterPlot :: [P2 Double]        -> State (Plot (ScatterOptions V2 Double (P2 Double)) b) () -> State (Axis b V2 Double) ()

Example

Expand

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.

scatterPlot' :: [(Double, Double)] -> State (Axis b V2 Double) ()
scatterPlot' :: [V2 Double]        -> State (Axis b V2 Double) ()
scatterPlot' :: [P2 Double]        -> State (Axis b V2 Double) ()

Example

Expand

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 ReifiedFold 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 ReifiedFold 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 :: [(Double, (Double, Double))] -> State (Plot (BubbleOptions v n) b) () -> State (Axis b V2 Double) ()
bubblePlot :: [(Double, V2 Double)]        -> State (Plot (BubbleOptions v n) b) () -> State (Axis b V2 Double) ()
bubblePlot :: [(Double, P2 Double)]        -> State (Plot (BubbleOptions v n) b) () -> State (Axis b V2 Double) ()

Example

Expand

import Plots
myweights = [2, 1.3, 1.8, 0.7]
mydata7 = zip myweights [(1,3), (2,5.5), (3.2, 6), (3.5, 6.1)]
mydata8 = mydata7 & each._2._2 *~ 0.5 & each._1 *~ 0.5
mydata9 = [(1, V2 1.2 2.7), (3, V2 2 5.1), (0.9, V2 3.2 2.6), (2, V2 3.5 5)]
bubbleAxis :: Axis B V2 Double
bubbleAxis = r2Axis &~ do
  bubblePlot mydata7 $ key "data 7"
  bubblePlot mydata8 $ key "data 8"
  bubblePlot mydata9 $ key "data 9"
bubbleExample = renderAxis bubbleAxis

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.

bubblePlot' :: [(Double, (Double, Double))] -> State (Axis b V2 Double) ()
bubblePlot' :: [(Double, V2 Double)]        -> State (Axis b V2 Double) ()

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 ReifiedFold 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 ReifiedFold 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.