plots-0.1.0.0: Diagrams based plotting library.

Safe HaskellNone
LanguageHaskell2010

Plots.Types.Density

Contents

Synopsis

GDensitylot plot

data GDensityPlot v n a #

Instances

(Metric v, OrderedField n) => Enveloped (GDensityPlot v n a) # 

Methods

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

(Typeable * a, TypeableFloat n, Renderable (Path V2 n) b) => Plotable (GDensityPlot V2 n a) b # 

Methods

renderPlotable :: InSpace v n (GDensityPlot V2 n a) => AxisSpec v n -> PlotStyle b v n -> GDensityPlot V2 n a -> QDiagram b v n Any #

defLegendPic :: InSpace v n (GDensityPlot V2 n a) => PlotStyle b v n -> GDensityPlot V2 n a -> QDiagram b v n Any #

type V (GDensityPlot v n a) # 
type V (GDensityPlot v n a) = v
type N (GDensityPlot v n a) # 
type N (GDensityPlot v n a) = n

Density plot

type DensityPlot v n = GDensityPlot v n (Point v n) #

mkDensityPlotOf :: (PointLike v n p, Ord n, Floating n, Enum n) => Fold s p -> s -> DensityPlot v n #

Make a density plot using a given fold.

mkDensityPlot :: (PointLike v n p, Foldable f, Ord n, Floating n, Enum n) => f p -> DensityPlot v n #

Make a density plot.

Helper funtions

densityY :: (Ord n, Floating n, Enum n) => [P2 n] -> Located (Trail' Line V2 n) #

Function used to create the density, takes the average of the xdata, bin y = 10.

Lenses

fillArea :: HasDensity a v n d => Lens' a Bool #

Density plot

densityPlot :: (v ~ BaseSpace c, PointLike v n p, MonadState (Axis b c n) m, Plotable (DensityPlot v n) b, Foldable f, Enum n) => f p -> State (Plot (DensityPlot v n) b) () -> m () #

Add a DenistyPlot to the AxisState from a data set.

Example

import Plots
import Plots.Types.Density

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]

densityAxis :: Axis B V2 Double
densityAxis = r2Axis &~ do
  densityPlot mydata1 $ key "data 1"
  densityPlot mydata2 $ key "data 2"
  densityPlot mydata3 $ key "data 3"
densityExample = renderAxis densityAxis

densityPlot' :: (v ~ BaseSpace c, PointLike v n p, MonadState (Axis b c n) m, Plotable (DensityPlot v n) b, Foldable f, Enum n) => f p -> m () #

Make a DensityPlot and take a State on the plot to alter it's options

  myaxis = r2Axis &~ do
    densityPlot' pointData1 $ do
      fillArea .= True
      addLegendEntry "data 1"

Fold variant density plot

densityPlotOf :: (v ~ BaseSpace c, PointLike v n p, MonadState (Axis b c n) m, Plotable (DensityPlot v n) b, Enum n) => Fold s p -> s -> State (Plot (DensityPlot v n) b) () -> m () #

Add a DensityPlot with the given name for the legend entry.

  myaxis = r2Axis &~ do
    densityPlotL "blue team" pointData1
    densityPlotL "red team" pointData2

densityPlotOf' :: (v ~ BaseSpace c, PointLike v n p, MonadState (Axis b c n) m, Plotable (DensityPlot v n) b, Enum n) => Fold s p -> s -> m () #