Copyright | (C) 2015 Christopher Chalmers |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Christopher Chalmers |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
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)
- data ScatterPlot v n
- data ScatterOptions v n a
- class HasScatterOptions f a d where
- class HasConnectingLine f a where
- scatterPlot :: (BaseSpace c ~ v, PointLike v n p, Typeable n, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b, Foldable f) => f p -> State (Plot (ScatterOptions v n (Point v n)) b) () -> m ()
- scatterPlot' :: (BaseSpace c ~ v, PointLike v n p, Typeable n, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b, Foldable f) => f p -> m ()
- scatterPlotOf :: (BaseSpace c ~ v, PointLike v n p, Typeable n, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b) => Fold s p -> s -> State (Plot (ScatterOptions v n (Point v n)) b) () -> m ()
- scatterPlotOf' :: (BaseSpace c ~ v, PointLike v n p, Typeable n, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b) => Fold s p -> s -> m ()
- scatterOptions :: (InSpace v n a, HasScatterOptions f a (Point v n)) => LensLike' f a (ScatterOptions v n (Point v n))
- bubblePlot :: (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) -> State (Plot (BubbleOptions v n) b) () -> m ()
- bubblePlot' :: (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) -> m ()
- bubblePlotOf :: (BaseSpace c ~ v, PointLike v n p, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b, Typeable n) => Fold s (n, p) -> s -> State (Plot (BubbleOptions v n) b) () -> m ()
- bubblePlotOf' :: (BaseSpace c ~ v, PointLike v n p, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b, Typeable n) => Fold s (n, p) -> s -> State (Plot (BubbleOptions v n) b) () -> m ()
- type BubbleOptions v n = ScatterOptions v n (n, Point v n)
- bubbleOptions :: (InSpace v n a, HasScatterOptions f a (n, Point v n)) => LensLike' f a (BubbleOptions v n)
- bubbleTransform :: (InSpace v n a, HasScatterOptions f a (n, Point v n), Settable f) => LensLike' f a (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)
- gscatterPlot :: (BaseSpace c ~ v, PointLike v n p, MonadState (Axis b c n) m, Plotable (ScatterPlot v n) b, Typeable d, Foldable f) => f d -> (d -> p) -> State (Plot (ScatterOptions v n d) b) () -> m ()
- gscatterOptionsFor :: (InSpace v n a, HasScatterOptions f a d) => proxy d -> LensLike' f a (ScatterOptions v n d)
- mkScatterOptions :: (PointLike v n p, Foldable f, Fractional n) => f a -> (a -> p) -> ScatterOptions v n a
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.
HasConnectingLine f (ScatterPlot v n) Source # | |
(Applicative f, Typeable (* -> *) v, Typeable * n, Typeable * d) => HasScatterOptions f (ScatterPlot v n) d Source # | |
(Metric v, OrderedField n) => Enveloped (ScatterPlot v n) Source # | |
(TypeableFloat n, Renderable (Path V2 n) b) => Plotable (ScatterPlot V2 n) b Source # | |
type V (ScatterPlot v n) Source # | |
type N (ScatterPlot v n) Source # | |
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.
HasConnectingLine f (ScatterOptions v n a) Source # | |
(~) * d d' => HasScatterOptions f (ScatterOptions v n d) d' Source # | |
type V (ScatterOptions v n a) Source # | |
type N (ScatterOptions v n a) Source # | |
class HasScatterOptions f a d where Source #
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.
(Functor f, HasScatterOptions f p a) => HasScatterOptions f (Plot p b) a 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 # | |
(Applicative f, Typeable * b, Typeable (* -> *) v, Typeable * n, Typeable * a) => HasScatterOptions f (DynamicPlot b v n) a 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.
HasConnectingLine f p => HasConnectingLine f (Plot p b) Source # | |
HasConnectingLine f (ScatterPlot v n) Source # | |
(Settable f, Typeable (* -> *) (BaseSpace c), Typeable * n) => HasConnectingLine f (Axis b c n) Source # | |
(Applicative f, Typeable (* -> *) v, Typeable * n) => HasConnectingLine f (StyledPlot b v n) Source # | |
(Applicative f, Typeable * b, Typeable (* -> *) v, Typeable * n) => HasConnectingLine f (DynamicPlot b v n) Source # | |
HasConnectingLine f (ScatterOptions v n a) Source # | |
Basic scatter plot
Add plots to the axis
:: (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 |
Add a ScatterPlot
to the AxisState
from a data set.
scatterPlot
:: [(Double
,Double
)] ->State
(Plot
(ScatterOptions
V2
Double
(P2
Double
)) b) () ->State
(Axis
bV2
Double
) ()scatterPlot
:: [V2
Double
] ->State
(Plot
(ScatterOptions
V2
Double
(P2
Double
)) b) () ->State
(Axis
bV2
Double
) ()scatterPlot
:: [P2
Double
] ->State
(Plot
(ScatterOptions
V2
Double
(P2
Double
)) b) () ->State
(Axis
bV2
Double
) ()
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
:: (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 |
Version of scatterPlot
without any changes to the
ScatterOptions
.
scatterPlot'
:: [(Double
,Double
)] ->State
(Axis
bV2
Double
) ()scatterPlot'
:: [V2
Double
] ->State
(Axis
bV2
Double
) ()scatterPlot'
:: [P2
Double
] ->State
(Axis
bV2
Double
) ()
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'
:: (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 |
Version of scatterPlot
that accepts a Fold
over the data.
:: (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
:: (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 |
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
bV2
Double
) ()bubblePlot
:: [(Double
,V2
Double
)] ->State
(Plot
(BubbleOptions
v n) b) () ->State
(Axis
bV2
Double
) ()bubblePlot
:: [(Double
,P2
Double
)] ->State
(Plot
(BubbleOptions
v n) b) () ->State
(Axis
bV2
Double
) ()
Example
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
:: (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 |
:: (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 |
Version of bubblePlot
using a Fold
over the data.
:: (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 |
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
, which would give a bubblePlot
.
scatterTransform
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
, which would give a bubblePlot
.
scatterTransform
LensLike
onto (n,
.Point
v n) -> Style
v n
General scatter plot
:: (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 |
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
.