Chart-1.9.4: A library for generating 2D Charts and Plots

Copyright | (c) Tim Docker 2014
License | BSD-style (see chart/COPYRIGHT)
Safe Haskell | Safe-Inferred
Language | Haskell98

Graphics.Rendering.Chart.Easy

Description

A high level API for generating a plot quickly.

Importing the Easy module brings into scope all core functions and types required for working with the chart library. This includes key external dependencies such as Control.Lens and Data.Colour. The module also provides several helper functions for quickly generating common plots. Note that chart backends must still be explicitly imported, as some backends cannot be built on all platforms.

Example usage:

    import Graphics.Rendering.Chart.Easy
    import Graphics.Rendering.Chart.Backend.Cairo

    signal :: [Double] -> [(Double,Double)]
    signal xs = [ (x,(sin (x*3.14159/45) + 1) / 2 * (sin (x*3.14159/5))) | x <- xs ]

    main = toFile def "example.png" $ do
        layout_title .= "Amplitude Modulation"
        plot (line "am" [signal [0,(0.5)..400]])
        plot (points "am points" (signal [0,7..400]))

More examples can be found on the library's wiki

Synopsis

- module Control.Lens
- module Data.Default.Class
- class ColourOps (f :: Type -> Type) where
  - darken :: Num a => a -> f a -> f a
- class AffineSpace (f :: Type -> Type) where
  - affineCombo :: Num a => [(a, f a)] -> f a -> f a
- data AlphaColour a
- data Colour a
- colourConvert :: (Fractional b, Real a) => Colour a -> Colour b
- black :: Num a => Colour a
- transparent :: Num a => AlphaColour a
- alphaColourConvert :: (Fractional b, Real a) => AlphaColour a -> AlphaColour b
- opaque :: Num a => Colour a -> AlphaColour a
- dissolve :: Num a => a -> AlphaColour a -> AlphaColour a
- withOpacity :: Num a => Colour a -> a -> AlphaColour a
- blend :: (Num a, AffineSpace f) => a -> f a -> f a -> f a
- atop :: Fractional a => AlphaColour a -> AlphaColour a -> AlphaColour a
- alphaChannel :: AlphaColour a -> a
- module Data.Colour.Names
- module Graphics.Rendering.Chart
- module Graphics.Rendering.Chart.State
- line :: String -> [[(x, y)]] -> EC l (PlotLines x y)
- points :: String -> [(x, y)] -> EC l (PlotPoints x y)
- bars :: (PlotValue x, BarsPlotValue y) => [String] -> [(x, [y])] -> EC l (PlotBars x y)
- setColors :: [AlphaColour Double] -> EC l ()
- setShapes :: [PointShape] -> EC l ()

# Documentation

module Control.Lens

module Data.Default.Class

class ColourOps (f :: Type -> Type) where Source #

Minimal complete definition

over, darken

Methods

darken :: Num a => a -> f a -> f a Source #

`darken s c` blends a colour with black without changing it's opacity.

For `Colour`, `darken s c = blend s c mempty`

#### Instances

Instances details

ColourOps AlphaColour |
Instance details Defined in Data.Colour.Internal Methods over :: Num a => AlphaColour a -> AlphaColour a -> AlphaColour a Source # darken :: Num a => a -> AlphaColour a -> AlphaColour a Source #
ColourOps Colour |
Instance details Defined in Data.Colour.Internal Methods over :: Num a => AlphaColour a -> Colour a -> Colour a Source # darken :: Num a => a -> Colour a -> Colour a Source #

class AffineSpace (f :: Type -> Type) where Source #

Methods

affineCombo :: Num a => [(a, f a)] -> f a -> f a Source #

Compute a affine Combination (weighted-average) of points. The last parameter will get the remaining weight. e.g.

    affineCombo [(0.2,a), (0.3,b)] c == 0.2*a + 0.3*b + 0.5*c

Weights can be negative, or greater than 1.0; however, be aware that non-convex combinations may lead to out of gamut colours.

#### Instances

Instances details

AffineSpace AlphaColour |
Instance details Defined in Data.Colour.Internal Methods affineCombo :: Num a => [(a, AlphaColour a)] -> AlphaColour a -> AlphaColour a Source #
AffineSpace Colour |
Instance details Defined in Data.Colour.Internal Methods affineCombo :: Num a => [(a, Colour a)] -> Colour a -> Colour a Source #

data AlphaColour a Source #

This type represents a `Colour` that may be semi-transparent.

The `Monoid` instance allows you to composite colours.

    x `mappend` y == x `over` y

To get the (pre-multiplied) colour channel of an `AlphaColour` `c`, simply composite `c` over black.

    c `over` black

#### Instances

Instances details

AffineSpace AlphaColour |
Instance details Defined in Data.Colour.Internal Methods affineCombo :: Num a => [(a, AlphaColour a)] -> AlphaColour a -> AlphaColour a Source #
ColourOps AlphaColour |
Instance details Defined in Data.Colour.Internal Methods over :: Num a => AlphaColour a -> AlphaColour a -> AlphaColour a Source # darken :: Num a => a -> AlphaColour a -> AlphaColour a Source #
Num a => Monoid (AlphaColour a) |
Instance details Defined in Data.Colour.Internal Methods mempty :: AlphaColour a Source # mappend :: AlphaColour a -> AlphaColour a -> AlphaColour a Source # mconcat :: [AlphaColour a] -> AlphaColour a Source #
Num a => Semigroup (AlphaColour a) | `AlphaColour` forms a monoid with `over` and `transparent`.
Instance details Defined in Data.Colour.Internal Methods (<>) :: AlphaColour a -> AlphaColour a -> AlphaColour a Source # sconcat :: NonEmpty (AlphaColour a) -> AlphaColour a Source # stimes :: Integral b => b -> AlphaColour a -> AlphaColour a Source #
Eq a => Eq (AlphaColour a) |
Instance details Defined in Data.Colour.Internal Methods (==) :: AlphaColour a -> AlphaColour a -> Bool Source # (/=) :: AlphaColour a -> AlphaColour a -> Bool Source #

data Colour a Source #

This type represents the human preception of colour. The `a` parameter is a numeric type used internally for the representation.

The `Monoid` instance allows one to add colours, but beware that adding colours can take you out of gamut. Consider using `blend` whenever possible.

#### Instances

Instances details

AffineSpace Colour |
Instance details Defined in Data.Colour.Internal Methods affineCombo :: Num a => [(a, Colour a)] -> Colour a -> Colour a Source #
ColourOps Colour |
Instance details Defined in Data.Colour.Internal Methods over :: Num a => AlphaColour a -> Colour a -> Colour a Source # darken :: Num a => a -> Colour a -> Colour a Source #
Num a => Monoid (Colour a) |
Instance details Defined in Data.Colour.Internal Methods mempty :: Colour a Source # mappend :: Colour a -> Colour a -> Colour a Source # mconcat :: [Colour a] -> Colour a Source #
Num a => Semigroup (Colour a) |
Instance details Defined in Data.Colour.Internal Methods (<>) :: Colour a -> Colour a -> Colour a Source # sconcat :: NonEmpty (Colour a) -> Colour a Source # stimes :: Integral b => b -> Colour a -> Colour a Source #
Eq a => Eq (Colour a) |
Instance details Defined in Data.Colour.Internal Methods (==) :: Colour a -> Colour a -> Bool Source # (/=) :: Colour a -> Colour a -> Bool Source #

colourConvert :: (Fractional b, Real a) => Colour a -> Colour b Source #

Change the type used to represent the colour coordinates.

black :: Num a => Colour a Source #

transparent :: Num a => AlphaColour a Source #

This `AlphaColour` is entirely transparent and has no associated colour channel.

alphaColourConvert :: (Fractional b, Real a) => AlphaColour a -> AlphaColour b Source #

Change the type used to represent the colour coordinates.

opaque :: Num a => Colour a -> AlphaColour a Source #

Creates an opaque `AlphaColour` from a `Colour`.

dissolve :: Num a => a -> AlphaColour a -> AlphaColour a Source #

Returns an `AlphaColour` more transparent by a factor of `o`.

withOpacity :: Num a => Colour a -> a -> AlphaColour a Source #

Creates an `AlphaColour` from a `Colour` with a given opacity.

    c `withOpacity` o == dissolve o (opaque c)

blend :: (Num a, AffineSpace f) => a -> f a -> f a -> f a Source #

Compute the weighted average of two points. e.g.

    blend 0.4 a b = 0.4*a + 0.6*b

The weight can be negative, or greater than 1.0; however, be aware that non-convex combinations may lead to out of gamut colours.

atop :: Fractional a => AlphaColour a -> AlphaColour a -> AlphaColour a Source #

`c1 `atop` c2` returns the `AlphaColour` produced by covering the portion of `c2` visible by `c1`. The resulting alpha channel is always the same as the alpha channel of `c2`.

    c1 `atop` (opaque c2) == c1 `over` (opaque c2)
    AlphaChannel (c1 `atop` c2) == AlphaChannel c2

alphaChannel :: AlphaColour a -> a Source #

Returns the opacity of an `AlphaColour`.

module Data.Colour.Names

module Graphics.Rendering.Chart

module Graphics.Rendering.Chart.State

line :: String -> [[(x, y)]] -> EC l (PlotLines x y) Source #

Constuct a line plot with the given title and data, using the next available color.

points :: String -> [(x, y)] -> EC l (PlotPoints x y) Source #

Construct a scatter plot with the given title and data, using the next available color and point shape.

bars :: (PlotValue x, BarsPlotValue y) => [String] -> [(x, [y])] -> EC l (PlotBars x y) Source #

Construct a bar chart with the given titles and data, using the next available colors

setColors :: [AlphaColour Double] -> EC l () Source #

Set the contents of the colour source, for subsequent plots

setShapes :: [PointShape] -> EC l () Source #

Set the contents of the shape source, for subsequent plots