{-# LANGUAGE DeriveDataTypeable    #-}
{-# LANGUAGE FlexibleContexts      #-}
{-# LANGUAGE FlexibleInstances     #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes            #-}
{-# LANGUAGE TypeFamilies          #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  Plots.Axis
-- Copyright   :  (C) 2015 Christopher Chalmers
-- License     :  BSD-style (see the file LICENSE)
-- Maintainer  :  Christopher Chalmers
-- Stability   :  experimental
-- Portability :  non-portable
--
-- The 'Axis' is the main data type for "plots". It holds all the
-- necessary infomation to be rendered into a 'Diagram'.
--
----------------------------------------------------------------------------
module Plots.Axis
  ( -- * Axis type
    Axis
  , axes
  , axisPlots
  , currentPlots
  , finalPlots
  , plotModifier
  , axisSize
  , colourBarRange

    -- * Predefined axes
  , r2Axis
  , polarAxis

    -- ** Base space
  , BaseSpace

    -- * Axis plots
  , addPlot
  , addPlotable
  , addPlotable'

    -- * Single axis
  , SingleAxis

    -- * Specific axes
    -- ** x-axis
  , xAxis
  , xLabel
  , xMin
  , xMax

    -- ** y-axis
  , yAxis
  , yLabel
  , yMin
  , yMax

    -- ** r-axis
  , rAxis
  , rLabel
  , rMax

    -- ** theta-axis
  , thetaAxis
  , thetaLabel

    -- ** z-axis
  , zAxis
  , zLabel
  , zMin
  , zMax
  ) where

import           Control.Monad.State
import           Data.Complex
import           Data.Default
import           Data.Kind
import           Data.Typeable

import           Diagrams.Coordinates.Polar
import           Diagrams.Prelude
import           Diagrams.TwoD.Text

import           Plots.Axis.ColourBar
import           Plots.Axis.Grid
import           Plots.Axis.Labels
import           Plots.Axis.Line
import           Plots.Axis.Scale
import           Plots.Axis.Title
import           Plots.Axis.Ticks
import           Plots.Legend
import           Plots.Style
import           Plots.Types

import           Linear

------------------------------------------------------------------------
-- Axis data type
------------------------------------------------------------------------

-- Single axis ---------------------------------------------------------

-- | Render information for a single axis line.
data SingleAxis b v n = SingleAxis
-- note the the v is only present for Style v n
  { forall b (v :: * -> *) n. SingleAxis b v n -> AxisLabel b v n
saLabel     :: AxisLabel b v n
  , forall b (v :: * -> *) n. SingleAxis b v n -> AxisLine v n
saLine      :: AxisLine v n
  , forall b (v :: * -> *) n. SingleAxis b v n -> TickLabels b v n
saTickLabel :: TickLabels b v n
  , forall b (v :: * -> *) n. SingleAxis b v n -> AxisScaling n
saScaling   :: AxisScaling n
  , forall b (v :: * -> *) n. SingleAxis b v n -> GridLines v n
saGridLines :: GridLines v n
  , forall b (v :: * -> *) n. SingleAxis b v n -> Ticks v n
saTicks     :: Ticks v n
  , forall b (v :: * -> *) n. SingleAxis b v n -> Bool
saVisible   :: Bool
  }

type instance V (SingleAxis b v n) = v
type instance N (SingleAxis b v n) = n

instance (TypeableFloat n, Renderable (Text n) b)
    => Default (SingleAxis b V2 n) where
  def :: SingleAxis b V2 n
def = SingleAxis
    { saLabel :: AxisLabel b V2 n
saLabel      = AxisLabel b V2 n
forall a. Default a => a
def
    , saLine :: AxisLine V2 n
saLine       = AxisLine V2 n
forall a. Default a => a
def
    , saTickLabel :: TickLabels b V2 n
saTickLabel  = TickLabels b V2 n
forall a. Default a => a
def
    , saGridLines :: GridLines V2 n
saGridLines  = GridLines V2 n
forall a. Default a => a
def
    , saTicks :: Ticks V2 n
saTicks      = Ticks V2 n
forall a. Default a => a
def
    , saScaling :: AxisScaling n
saScaling    = AxisScaling n
forall a. Default a => a
def
    , saVisible :: Bool
saVisible    = Bool
True
    }

instance Functor f => HasTicks f (SingleAxis b v n) where
  bothTicks :: LensLike'
  f
  (SingleAxis b v n)
  (Ticks (V (SingleAxis b v n)) (N (SingleAxis b v n)))
bothTicks = (SingleAxis b v n -> Ticks v n)
-> (SingleAxis b v n -> Ticks v n -> SingleAxis b v n)
-> Lens
     (SingleAxis b v n) (SingleAxis b v n) (Ticks v n) (Ticks v n)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens SingleAxis b v n -> Ticks v n
forall b (v :: * -> *) n. SingleAxis b v n -> Ticks v n
saTicks (\SingleAxis b v n
sa Ticks v n
ticks -> SingleAxis b v n
sa {saTicks :: Ticks v n
saTicks = Ticks v n
ticks})

instance Functor f => HasMajorTicks f (SingleAxis b v n) where
  majorTicks :: LensLike'
  f
  (SingleAxis b v n)
  (MajorTicks (V (SingleAxis b v n)) (N (SingleAxis b v n)))
majorTicks = (Ticks v n -> f (Ticks v n))
-> SingleAxis b v n -> f (SingleAxis b v n)
forall (f :: * -> *) a.
HasTicks f a =>
LensLike' f a (Ticks (V a) (N a))
bothTicks ((Ticks v n -> f (Ticks v n))
 -> SingleAxis b v n -> f (SingleAxis b v n))
-> ((MajorTicks v n -> f (MajorTicks v n))
    -> Ticks v n -> f (Ticks v n))
-> (MajorTicks v n -> f (MajorTicks v n))
-> SingleAxis b v n
-> f (SingleAxis b v n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (MajorTicks v n -> f (MajorTicks v n))
-> Ticks v n -> f (Ticks v n)
forall (f :: * -> *) a.
HasMajorTicks f a =>
LensLike' f a (MajorTicks (V a) (N a))
majorTicks

instance Functor f => HasMinorTicks f (SingleAxis b v n) where
  minorTicks :: LensLike'
  f
  (SingleAxis b v n)
  (MinorTicks (V (SingleAxis b v n)) (N (SingleAxis b v n)))
minorTicks = (Ticks v n -> f (Ticks v n))
-> SingleAxis b v n -> f (SingleAxis b v n)
forall (f :: * -> *) a.
HasTicks f a =>
LensLike' f a (Ticks (V a) (N a))
bothTicks ((Ticks v n -> f (Ticks v n))
 -> SingleAxis b v n -> f (SingleAxis b v n))
-> ((MinorTicks v n -> f (MinorTicks v n))
    -> Ticks v n -> f (Ticks v n))
-> (MinorTicks v n -> f (MinorTicks v n))
-> SingleAxis b v n
-> f (SingleAxis b v n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (MinorTicks v n -> f (MinorTicks v n))
-> Ticks v n -> f (Ticks v n)
forall (f :: * -> *) a.
HasMinorTicks f a =>
LensLike' f a (MinorTicks (V a) (N a))
minorTicks

instance Functor f => HasAxisLabel f (SingleAxis b v n) b where
  axisLabel :: LensLike'
  f
  (SingleAxis b v n)
  (AxisLabel b (V (SingleAxis b v n)) (N (SingleAxis b v n)))
axisLabel = (SingleAxis b v n -> AxisLabel b v n)
-> (SingleAxis b v n -> AxisLabel b v n -> SingleAxis b v n)
-> Lens
     (SingleAxis b v n)
     (SingleAxis b v n)
     (AxisLabel b v n)
     (AxisLabel b v n)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens SingleAxis b v n -> AxisLabel b v n
forall b (v :: * -> *) n. SingleAxis b v n -> AxisLabel b v n
saLabel (\SingleAxis b v n
sa AxisLabel b v n
l -> SingleAxis b v n
sa {saLabel :: AxisLabel b v n
saLabel = AxisLabel b v n
l})

instance Functor f => HasTickLabels f (SingleAxis b v n) b where
  tickLabel :: LensLike'
  f
  (SingleAxis b v n)
  (TickLabels b (V (SingleAxis b v n)) (N (SingleAxis b v n)))
tickLabel = (SingleAxis b v n -> TickLabels b v n)
-> (SingleAxis b v n -> TickLabels b v n -> SingleAxis b v n)
-> Lens
     (SingleAxis b v n)
     (SingleAxis b v n)
     (TickLabels b v n)
     (TickLabels b v n)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens SingleAxis b v n -> TickLabels b v n
forall b (v :: * -> *) n. SingleAxis b v n -> TickLabels b v n
saTickLabel (\SingleAxis b v n
sa TickLabels b v n
tl -> SingleAxis b v n
sa {saTickLabel :: TickLabels b v n
saTickLabel = TickLabels b v n
tl})

instance Functor f => HasAxisLine f (SingleAxis b v n) where
  axisLine :: LensLike'
  f
  (SingleAxis b v n)
  (AxisLine (V (SingleAxis b v n)) (N (SingleAxis b v n)))
axisLine = (SingleAxis b v n -> AxisLine v n)
-> (SingleAxis b v n -> AxisLine v n -> SingleAxis b v n)
-> Lens
     (SingleAxis b v n) (SingleAxis b v n) (AxisLine v n) (AxisLine v n)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens SingleAxis b v n -> AxisLine v n
forall b (v :: * -> *) n. SingleAxis b v n -> AxisLine v n
saLine (\SingleAxis b v n
sa AxisLine v n
l -> SingleAxis b v n
sa {saLine :: AxisLine v n
saLine = AxisLine v n
l})

instance Functor f => HasGridLines f (SingleAxis b v n) where
  gridLines :: LensLike'
  f
  (SingleAxis b v n)
  (GridLines (V (SingleAxis b v n)) (N (SingleAxis b v n)))
gridLines = (SingleAxis b v n -> GridLines v n)
-> (SingleAxis b v n -> GridLines v n -> SingleAxis b v n)
-> Lens
     (SingleAxis b v n)
     (SingleAxis b v n)
     (GridLines v n)
     (GridLines v n)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens SingleAxis b v n -> GridLines v n
forall b (v :: * -> *) n. SingleAxis b v n -> GridLines v n
saGridLines (\SingleAxis b v n
sa GridLines v n
l -> SingleAxis b v n
sa {saGridLines :: GridLines v n
saGridLines = GridLines v n
l})

instance Functor f => HasMajorGridLines f (SingleAxis b v n) where
  majorGridLines :: LensLike'
  f
  (SingleAxis b v n)
  (MajorGridLines (V (SingleAxis b v n)) (N (SingleAxis b v n)))
majorGridLines = (GridLines v n -> f (GridLines v n))
-> SingleAxis b v n -> f (SingleAxis b v n)
forall (f :: * -> *) a.
HasGridLines f a =>
LensLike' f a (GridLines (V a) (N a))
gridLines ((GridLines v n -> f (GridLines v n))
 -> SingleAxis b v n -> f (SingleAxis b v n))
-> ((MajorGridLines v n -> f (MajorGridLines v n))
    -> GridLines v n -> f (GridLines v n))
-> (MajorGridLines v n -> f (MajorGridLines v n))
-> SingleAxis b v n
-> f (SingleAxis b v n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (MajorGridLines v n -> f (MajorGridLines v n))
-> GridLines v n -> f (GridLines v n)
forall (f :: * -> *) a.
HasMajorGridLines f a =>
LensLike' f a (MajorGridLines (V a) (N a))
majorGridLines

instance Functor f => HasMinorGridLines f (SingleAxis b v n) where
  minorGridLines :: LensLike'
  f
  (SingleAxis b v n)
  (MinorGridLines (V (SingleAxis b v n)) (N (SingleAxis b v n)))
minorGridLines = (GridLines v n -> f (GridLines v n))
-> SingleAxis b v n -> f (SingleAxis b v n)
forall (f :: * -> *) a.
HasGridLines f a =>
LensLike' f a (GridLines (V a) (N a))
gridLines ((GridLines v n -> f (GridLines v n))
 -> SingleAxis b v n -> f (SingleAxis b v n))
-> ((MinorGridLines v n -> f (MinorGridLines v n))
    -> GridLines v n -> f (GridLines v n))
-> (MinorGridLines v n -> f (MinorGridLines v n))
-> SingleAxis b v n
-> f (SingleAxis b v n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (MinorGridLines v n -> f (MinorGridLines v n))
-> GridLines v n -> f (GridLines v n)
forall (f :: * -> *) a.
HasMinorGridLines f a =>
LensLike' f a (MinorGridLines (V a) (N a))
minorGridLines

instance Functor f => HasAxisScaling f (SingleAxis b v n) where
  axisScaling :: LensLike' f (SingleAxis b v n) (AxisScaling (N (SingleAxis b v n)))
axisScaling = (SingleAxis b v n -> AxisScaling n)
-> (SingleAxis b v n -> AxisScaling n -> SingleAxis b v n)
-> Lens
     (SingleAxis b v n)
     (SingleAxis b v n)
     (AxisScaling n)
     (AxisScaling n)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens SingleAxis b v n -> AxisScaling n
forall b (v :: * -> *) n. SingleAxis b v n -> AxisScaling n
saScaling (\SingleAxis b v n
sa AxisScaling n
s -> SingleAxis b v n
sa {saScaling :: AxisScaling n
saScaling = AxisScaling n
s})

instance HasVisibility (SingleAxis b v n) where
  visible :: Lens' (SingleAxis b v n) Bool
visible = (SingleAxis b v n -> Bool)
-> (SingleAxis b v n -> Bool -> SingleAxis b v n)
-> Lens' (SingleAxis b v n) Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens SingleAxis b v n -> Bool
forall b (v :: * -> *) n. SingleAxis b v n -> Bool
saVisible (\SingleAxis b v n
sa Bool
b -> SingleAxis b v n
sa {saVisible :: Bool
saVisible = Bool
b})

-- singleAxisScale :: Lens' (SingleAxis b v n) AxisScale
-- singleAxisScale = lens saScale (\sa s -> sa {saScale = s})

-- singleAxisBound :: Lens' (SingleAxis b v n) (Bound n)
-- singleAxisBound = lens saBounds (\sa b -> sa {saBounds = b})

------------------------------------------------------------------------
-- Axis type
------------------------------------------------------------------------

-- Base space ----------------------------------------------------------

-- | This family is used so that we can say (Axis Polar) but use V2 for the
--   underlying diagram.
type family BaseSpace (c :: Type -> Type) :: Type -> Type

type instance BaseSpace V2      = V2
type instance BaseSpace Complex = V2
type instance BaseSpace Polar   = V2
type instance BaseSpace V3      = V3

-- Axis data type ------------------------------------------------------

-- | Axis is the data type that holds all the necessary information to render
--   a plot. Common 'LensLike's used for the axis (see haddock's
--   instances for a more comprehensive list):
--
--   * 'axisStyle'    - customise the 'AxisStyle'
--   * 'legend'       - customise the 'Legend'
--   * 'colourBar'    - customise the 'ColourBar'
--   * 'currentPlots' - current plots in the 'Axis'
--   * 'finalPlots'   - changes to the plots just before rendering
--   * 'axes'         - changes to each 'SingleAxis'
--
--          * 'xAxis' - the x-axis
--          * 'yAxis' - the y-axis
--          * 'zAxis' - the z-axis
--
--   The following 'LensLike's can be used on the on all the axes by
--   applying it the to 'Axis' or can be used on a 'SingleAxis' by using
--   it in combination with a specific axis (like 'xAxis').
--
--   * 'axisLabel'   - customise the 'MinorTicks'
--   * 'tickLabel'   - customise the 'TickLabels'
--   * 'minorTicks'  - customise the 'MinorTicks'
--   * 'majorTicks'  - customise the 'MajorTicks'
--   * 'gridLines'   - customise the 'GridLines'
--   * 'axisLine'    - customise the 'AxisLine'
--   * 'axisScaling' - customise the 'AxisScaling'
--
--   Plots are usually added to the axis using specific functions for
--   those plots ('Plots.Types.Line.linePlot, 'Plots.Types.Bar.barPlot').
--   These functions use 'addPlotable' to add the plot to the axis.
data Axis b c n = Axis
  { forall b (c :: * -> *) n. Axis b c n -> AxisStyle b (BaseSpace c) n
_axisStyle   :: AxisStyle b (BaseSpace c) n
  , forall b (c :: * -> *) n. Axis b c n -> ColourBar b n
_colourBar   :: ColourBar b n
  , forall b (c :: * -> *) n. Axis b c n -> (n, n)
_colourBarR  :: (n,n)
  , forall b (c :: * -> *) n. Axis b c n -> Legend b n
_legend      :: Legend b n
  , forall b (c :: * -> *) n. Axis b c n -> Title b (BaseSpace c) n
_axisTitle   :: Title b (BaseSpace c) n
  -- , _axisTitle      :: AxisTitle

  , forall b (c :: * -> *) n.
Axis b c n -> [DynamicPlot b (BaseSpace c) n]
_axisPlots   :: [DynamicPlot b (BaseSpace c) n]
  , forall b (c :: * -> *) n.
Axis b c n -> Endo (StyledPlot b (BaseSpace c) n)
_plotModifier :: Endo (StyledPlot b (BaseSpace c) n)

  -- the v in each axis is only used for the style
  , forall b (c :: * -> *) n.
Axis b c n -> c (SingleAxis b (BaseSpace c) n)
_axes        :: c (SingleAxis b (BaseSpace c) n)
  } deriving Typeable

-- | Lens onto the separate axes of an axis. Allows changing the
--   coordinate system as long as the 'BaseSpace' is the same.
--
-- @
-- 'axes' :: 'Lens'' ('Axis' b c n) (c ('SingleAxis' b v n))
-- @
axes :: (v ~ BaseSpace c, v ~ BaseSpace c')
     => Lens (Axis b c  n)
             (Axis b c' n)
             (c  (SingleAxis b v n))
             (c' (SingleAxis b v n))
axes :: forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes = (Axis b c n -> c (SingleAxis b v n))
-> (Axis b c n -> c' (SingleAxis b v n) -> Axis b c' n)
-> Lens
     (Axis b c n)
     (Axis b c' n)
     (c (SingleAxis b v n))
     (c' (SingleAxis b v n))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Axis b c n -> c (SingleAxis b v n)
forall b (c :: * -> *) n.
Axis b c n -> c (SingleAxis b (BaseSpace c) n)
_axes (\(Axis AxisStyle b (BaseSpace c) n
a1 ColourBar b n
a2 (n, n)
a3 Legend b n
a4 Title b (BaseSpace c) n
a5 [DynamicPlot b (BaseSpace c) n]
a6 Endo (StyledPlot b (BaseSpace c) n)
a7 c (SingleAxis b (BaseSpace c) n)
_) c' (SingleAxis b v n)
a8 -> AxisStyle b (BaseSpace c') n
-> ColourBar b n
-> (n, n)
-> Legend b n
-> Title b (BaseSpace c') n
-> [DynamicPlot b (BaseSpace c') n]
-> Endo (StyledPlot b (BaseSpace c') n)
-> c' (SingleAxis b (BaseSpace c') n)
-> Axis b c' n
forall b (c :: * -> *) n.
AxisStyle b (BaseSpace c) n
-> ColourBar b n
-> (n, n)
-> Legend b n
-> Title b (BaseSpace c) n
-> [DynamicPlot b (BaseSpace c) n]
-> Endo (StyledPlot b (BaseSpace c) n)
-> c (SingleAxis b (BaseSpace c) n)
-> Axis b c n
Axis AxisStyle b (BaseSpace c) n
AxisStyle b (BaseSpace c') n
a1 ColourBar b n
a2 (n, n)
a3 Legend b n
a4 Title b (BaseSpace c) n
Title b (BaseSpace c') n
a5 [DynamicPlot b (BaseSpace c) n]
[DynamicPlot b (BaseSpace c') n]
a6 Endo (StyledPlot b (BaseSpace c) n)
Endo (StyledPlot b (BaseSpace c') n)
a7 c' (SingleAxis b v n)
c' (SingleAxis b (BaseSpace c') n)
a8)

-- | The list of plots currently in the axis.
axisPlots :: BaseSpace c ~ v => Lens' (Axis b c n) [DynamicPlot b v n]
axisPlots :: forall (c :: * -> *) (v :: * -> *) b n.
(BaseSpace c ~ v) =>
Lens' (Axis b c n) [DynamicPlot b v n]
axisPlots = (Axis b c n -> [DynamicPlot b v n])
-> (Axis b c n -> [DynamicPlot b v n] -> Axis b c n)
-> Lens
     (Axis b c n) (Axis b c n) [DynamicPlot b v n] [DynamicPlot b v n]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Axis b c n -> [DynamicPlot b v n]
forall b (c :: * -> *) n.
Axis b c n -> [DynamicPlot b (BaseSpace c) n]
_axisPlots (\Axis b c n
a [DynamicPlot b v n]
ps -> Axis b c n
a {_axisPlots :: [DynamicPlot b (BaseSpace c) n]
_axisPlots = [DynamicPlot b v n]
[DynamicPlot b (BaseSpace c) n]
ps})

-- | Traversal over the current plots in the axis.
--
--   For example, to make all 'ScatterPlot's currently in the axis use a
--   'connectingLine', you can write
--
-- @
-- 'finalPlots' . 'connectingLine' .= 'True'
-- @
currentPlots :: BaseSpace c ~ v => Traversal' (Axis b c n) (DynamicPlot b v n)
currentPlots :: forall (c :: * -> *) (v :: * -> *) b n.
(BaseSpace c ~ v) =>
Traversal' (Axis b c n) (DynamicPlot b v n)
currentPlots = ([DynamicPlot b v n] -> f [DynamicPlot b v n])
-> Axis b c n -> f (Axis b c n)
forall (c :: * -> *) (v :: * -> *) b n.
(BaseSpace c ~ v) =>
Lens' (Axis b c n) [DynamicPlot b v n]
axisPlots (([DynamicPlot b v n] -> f [DynamicPlot b v n])
 -> Axis b c n -> f (Axis b c n))
-> ((DynamicPlot b v n -> f (DynamicPlot b v n))
    -> [DynamicPlot b v n] -> f [DynamicPlot b v n])
-> (DynamicPlot b v n -> f (DynamicPlot b v n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DynamicPlot b v n -> f (DynamicPlot b v n))
-> [DynamicPlot b v n] -> f [DynamicPlot b v n]
forall (f :: * -> *) a b.
Traversable f =>
IndexedTraversal Int (f a) (f b) a b
traversed

-- | Setter over the final plot before the axis is rendered.
--
--   For example, to make all 'ScatterPlot's in the axis use a
--   'connectingLine' (both currently in the axis and ones added later),
--   you can add
--
-- @
-- 'finalPlots' . 'connectingLine' .= 'True'
-- @
--
finalPlots :: BaseSpace c ~ v => Setter' (Axis b c n) (StyledPlot b v n)
finalPlots :: forall (c :: * -> *) (v :: * -> *) b n.
(BaseSpace c ~ v) =>
Setter' (Axis b c n) (StyledPlot b v n)
finalPlots = ((StyledPlot b v n -> StyledPlot b v n)
 -> Axis b c n -> Axis b c n)
-> Optical
     (->)
     (->)
     f
     (Axis b c n)
     (Axis b c n)
     (StyledPlot b v n)
     (StyledPlot b v n)
forall (p :: * -> * -> *) (q :: * -> * -> *) (f :: * -> *) a b s t.
(Profunctor p, Profunctor q, Settable f) =>
(p a b -> q s t) -> Optical p q f s t a b
sets (((StyledPlot b v n -> StyledPlot b v n)
  -> Axis b c n -> Axis b c n)
 -> Optical
      (->)
      (->)
      f
      (Axis b c n)
      (Axis b c n)
      (StyledPlot b v n)
      (StyledPlot b v n))
-> ((StyledPlot b v n -> StyledPlot b v n)
    -> Axis b c n -> Axis b c n)
-> Optical
     (->)
     (->)
     f
     (Axis b c n)
     (Axis b c n)
     (StyledPlot b v n)
     (StyledPlot b v n)
forall a b. (a -> b) -> a -> b
$ \StyledPlot b v n -> StyledPlot b v n
f Axis b c n
a -> Axis b c n
a {_plotModifier :: Endo (StyledPlot b (BaseSpace c) n)
_plotModifier = Axis b c n -> Endo (StyledPlot b (BaseSpace c) n)
forall b (c :: * -> *) n.
Axis b c n -> Endo (StyledPlot b (BaseSpace c) n)
_plotModifier Axis b c n
a Endo (StyledPlot b v n)
-> Endo (StyledPlot b v n) -> Endo (StyledPlot b v n)
forall a. Semigroup a => a -> a -> a
<> (StyledPlot b v n -> StyledPlot b v n) -> Endo (StyledPlot b v n)
forall a. (a -> a) -> Endo a
Endo StyledPlot b v n -> StyledPlot b v n
f}

-- | Lens onto the modifier set by 'finalPlots'. This gets applied to
--   all plots in the axis, just before they are rendered.
plotModifier :: BaseSpace c ~ v => Lens' (Axis b c n) (Endo (StyledPlot b v n))
plotModifier :: forall (c :: * -> *) (v :: * -> *) b n.
(BaseSpace c ~ v) =>
Lens' (Axis b c n) (Endo (StyledPlot b v n))
plotModifier = (Axis b c n -> Endo (StyledPlot b v n))
-> (Axis b c n -> Endo (StyledPlot b v n) -> Axis b c n)
-> Lens
     (Axis b c n)
     (Axis b c n)
     (Endo (StyledPlot b v n))
     (Endo (StyledPlot b v n))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Axis b c n -> Endo (StyledPlot b v n)
forall b (c :: * -> *) n.
Axis b c n -> Endo (StyledPlot b (BaseSpace c) n)
_plotModifier (\Axis b c n
a Endo (StyledPlot b v n)
f -> Axis b c n
a {_plotModifier :: Endo (StyledPlot b (BaseSpace c) n)
_plotModifier = Endo (StyledPlot b v n)
Endo (StyledPlot b (BaseSpace c) n)
f})

-- Axis instances ------------------------------------------------------

type instance V (Axis b v n) = BaseSpace v
type instance N (Axis b v n) = n

instance (Applicative f, Traversable c) => HasTicks f (Axis b c n) where
  bothTicks :: LensLike' f (Axis b c n) (Ticks (V (Axis b c n)) (N (Axis b c n)))
bothTicks = (c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> Axis b c n -> f (Axis b c n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes ((c (SingleAxis b (BaseSpace c) n)
  -> f (c (SingleAxis b (BaseSpace c) n)))
 -> Axis b c n -> f (Axis b c n))
-> ((Ticks (BaseSpace c) n -> f (Ticks (BaseSpace c) n))
    -> c (SingleAxis b (BaseSpace c) n)
    -> f (c (SingleAxis b (BaseSpace c) n)))
-> (Ticks (BaseSpace c) n -> f (Ticks (BaseSpace c) n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> ((Ticks (BaseSpace c) n -> f (Ticks (BaseSpace c) n))
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (Ticks (BaseSpace c) n -> f (Ticks (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Ticks (BaseSpace c) n -> f (Ticks (BaseSpace c) n))
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a.
HasTicks f a =>
LensLike' f a (Ticks (V a) (N a))
bothTicks

instance (Applicative f, Traversable c) => HasMajorTicks f (Axis b c n) where
  majorTicks :: LensLike'
  f (Axis b c n) (MajorTicks (V (Axis b c n)) (N (Axis b c n)))
majorTicks = (c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> Axis b c n -> f (Axis b c n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes ((c (SingleAxis b (BaseSpace c) n)
  -> f (c (SingleAxis b (BaseSpace c) n)))
 -> Axis b c n -> f (Axis b c n))
-> ((MajorTicks (BaseSpace c) n -> f (MajorTicks (BaseSpace c) n))
    -> c (SingleAxis b (BaseSpace c) n)
    -> f (c (SingleAxis b (BaseSpace c) n)))
-> (MajorTicks (BaseSpace c) n -> f (MajorTicks (BaseSpace c) n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> ((MajorTicks (BaseSpace c) n -> f (MajorTicks (BaseSpace c) n))
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (MajorTicks (BaseSpace c) n -> f (MajorTicks (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (MajorTicks (BaseSpace c) n -> f (MajorTicks (BaseSpace c) n))
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a.
HasMajorTicks f a =>
LensLike' f a (MajorTicks (V a) (N a))
majorTicks

instance (Applicative f, Traversable c) => HasMinorTicks f (Axis b c n) where
  minorTicks :: LensLike'
  f (Axis b c n) (MinorTicks (V (Axis b c n)) (N (Axis b c n)))
minorTicks = (c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> Axis b c n -> f (Axis b c n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes ((c (SingleAxis b (BaseSpace c) n)
  -> f (c (SingleAxis b (BaseSpace c) n)))
 -> Axis b c n -> f (Axis b c n))
-> ((MinorTicks (BaseSpace c) n -> f (MinorTicks (BaseSpace c) n))
    -> c (SingleAxis b (BaseSpace c) n)
    -> f (c (SingleAxis b (BaseSpace c) n)))
-> (MinorTicks (BaseSpace c) n -> f (MinorTicks (BaseSpace c) n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> ((MinorTicks (BaseSpace c) n -> f (MinorTicks (BaseSpace c) n))
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (MinorTicks (BaseSpace c) n -> f (MinorTicks (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (MinorTicks (BaseSpace c) n -> f (MinorTicks (BaseSpace c) n))
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a.
HasMinorTicks f a =>
LensLike' f a (MinorTicks (V a) (N a))
minorTicks

instance (Applicative f, Traversable c) => HasGridLines f (Axis b c n) where
  gridLines :: LensLike'
  f (Axis b c n) (GridLines (V (Axis b c n)) (N (Axis b c n)))
gridLines = (c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> Axis b c n -> f (Axis b c n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes ((c (SingleAxis b (BaseSpace c) n)
  -> f (c (SingleAxis b (BaseSpace c) n)))
 -> Axis b c n -> f (Axis b c n))
-> ((GridLines (BaseSpace c) n -> f (GridLines (BaseSpace c) n))
    -> c (SingleAxis b (BaseSpace c) n)
    -> f (c (SingleAxis b (BaseSpace c) n)))
-> (GridLines (BaseSpace c) n -> f (GridLines (BaseSpace c) n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> ((GridLines (BaseSpace c) n -> f (GridLines (BaseSpace c) n))
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (GridLines (BaseSpace c) n -> f (GridLines (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (GridLines (BaseSpace c) n -> f (GridLines (BaseSpace c) n))
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a.
HasGridLines f a =>
LensLike' f a (GridLines (V a) (N a))
gridLines

instance (Applicative f, Traversable c) => HasMajorGridLines f (Axis b c n) where
  majorGridLines :: LensLike'
  f (Axis b c n) (MajorGridLines (V (Axis b c n)) (N (Axis b c n)))
majorGridLines = (c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> Axis b c n -> f (Axis b c n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes ((c (SingleAxis b (BaseSpace c) n)
  -> f (c (SingleAxis b (BaseSpace c) n)))
 -> Axis b c n -> f (Axis b c n))
-> ((MajorGridLines (BaseSpace c) n
     -> f (MajorGridLines (BaseSpace c) n))
    -> c (SingleAxis b (BaseSpace c) n)
    -> f (c (SingleAxis b (BaseSpace c) n)))
-> (MajorGridLines (BaseSpace c) n
    -> f (MajorGridLines (BaseSpace c) n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> ((MajorGridLines (BaseSpace c) n
     -> f (MajorGridLines (BaseSpace c) n))
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (MajorGridLines (BaseSpace c) n
    -> f (MajorGridLines (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (MajorGridLines (BaseSpace c) n
 -> f (MajorGridLines (BaseSpace c) n))
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a.
HasMajorGridLines f a =>
LensLike' f a (MajorGridLines (V a) (N a))
majorGridLines

instance (Applicative f, Traversable c) => HasMinorGridLines f (Axis b c n) where
  minorGridLines :: LensLike'
  f (Axis b c n) (MinorGridLines (V (Axis b c n)) (N (Axis b c n)))
minorGridLines = (c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> Axis b c n -> f (Axis b c n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes ((c (SingleAxis b (BaseSpace c) n)
  -> f (c (SingleAxis b (BaseSpace c) n)))
 -> Axis b c n -> f (Axis b c n))
-> ((MinorGridLines (BaseSpace c) n
     -> f (MinorGridLines (BaseSpace c) n))
    -> c (SingleAxis b (BaseSpace c) n)
    -> f (c (SingleAxis b (BaseSpace c) n)))
-> (MinorGridLines (BaseSpace c) n
    -> f (MinorGridLines (BaseSpace c) n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> ((MinorGridLines (BaseSpace c) n
     -> f (MinorGridLines (BaseSpace c) n))
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (MinorGridLines (BaseSpace c) n
    -> f (MinorGridLines (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (MinorGridLines (BaseSpace c) n
 -> f (MinorGridLines (BaseSpace c) n))
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a.
HasMinorGridLines f a =>
LensLike' f a (MinorGridLines (V a) (N a))
minorGridLines

instance (Applicative f, Traversable c) => HasAxisLabel f (Axis b c n) b where
  axisLabel :: LensLike'
  f (Axis b c n) (AxisLabel b (V (Axis b c n)) (N (Axis b c n)))
axisLabel = (c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> Axis b c n -> f (Axis b c n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes ((c (SingleAxis b (BaseSpace c) n)
  -> f (c (SingleAxis b (BaseSpace c) n)))
 -> Axis b c n -> f (Axis b c n))
-> ((AxisLabel b (BaseSpace c) n
     -> f (AxisLabel b (BaseSpace c) n))
    -> c (SingleAxis b (BaseSpace c) n)
    -> f (c (SingleAxis b (BaseSpace c) n)))
-> (AxisLabel b (BaseSpace c) n -> f (AxisLabel b (BaseSpace c) n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> ((AxisLabel b (BaseSpace c) n
     -> f (AxisLabel b (BaseSpace c) n))
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (AxisLabel b (BaseSpace c) n -> f (AxisLabel b (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AxisLabel b (BaseSpace c) n -> f (AxisLabel b (BaseSpace c) n))
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a b.
HasAxisLabel f a b =>
LensLike' f a (AxisLabel b (V a) (N a))
axisLabel

instance (Applicative f, Traversable c) => HasTickLabels f (Axis b c n) b where
  tickLabel :: LensLike'
  f (Axis b c n) (TickLabels b (V (Axis b c n)) (N (Axis b c n)))
tickLabel = (c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> Axis b c n -> f (Axis b c n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes ((c (SingleAxis b (BaseSpace c) n)
  -> f (c (SingleAxis b (BaseSpace c) n)))
 -> Axis b c n -> f (Axis b c n))
-> ((TickLabels b (BaseSpace c) n
     -> f (TickLabels b (BaseSpace c) n))
    -> c (SingleAxis b (BaseSpace c) n)
    -> f (c (SingleAxis b (BaseSpace c) n)))
-> (TickLabels b (BaseSpace c) n
    -> f (TickLabels b (BaseSpace c) n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> ((TickLabels b (BaseSpace c) n
     -> f (TickLabels b (BaseSpace c) n))
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (TickLabels b (BaseSpace c) n
    -> f (TickLabels b (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TickLabels b (BaseSpace c) n -> f (TickLabels b (BaseSpace c) n))
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a b.
HasTickLabels f a b =>
LensLike' f a (TickLabels b (V a) (N a))
tickLabel

instance (Applicative f, Traversable c) => HasAxisScaling f (Axis b c n) where
  axisScaling :: LensLike' f (Axis b c n) (AxisScaling (N (Axis b c n)))
axisScaling = (c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> Axis b c n -> f (Axis b c n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes ((c (SingleAxis b (BaseSpace c) n)
  -> f (c (SingleAxis b (BaseSpace c) n)))
 -> Axis b c n -> f (Axis b c n))
-> ((AxisScaling n -> f (AxisScaling n))
    -> c (SingleAxis b (BaseSpace c) n)
    -> f (c (SingleAxis b (BaseSpace c) n)))
-> (AxisScaling n -> f (AxisScaling n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> ((AxisScaling n -> f (AxisScaling n))
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (AxisScaling n -> f (AxisScaling n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (AxisScaling n -> f (AxisScaling n))
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a.
HasAxisScaling f a =>
LensLike' f a (AxisScaling (N a))
axisScaling

instance Settable f => HasPlotOptions f (Axis b c n) b where
  plotOptions :: LensLike'
  f (Axis b c n) (PlotOptions b (V (Axis b c n)) (N (Axis b c n)))
plotOptions = (StyledPlot b (BaseSpace c) n -> f (StyledPlot b (BaseSpace c) n))
-> Axis b c n -> f (Axis b c n)
forall (c :: * -> *) (v :: * -> *) b n.
(BaseSpace c ~ v) =>
Setter' (Axis b c n) (StyledPlot b v n)
finalPlots ((StyledPlot b (BaseSpace c) n -> f (StyledPlot b (BaseSpace c) n))
 -> Axis b c n -> f (Axis b c n))
-> ((PlotOptions b (BaseSpace c) n
     -> f (PlotOptions b (BaseSpace c) n))
    -> StyledPlot b (BaseSpace c) n
    -> f (StyledPlot b (BaseSpace c) n))
-> (PlotOptions b (BaseSpace c) n
    -> f (PlotOptions b (BaseSpace c) n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PlotOptions b (BaseSpace c) n
 -> f (PlotOptions b (BaseSpace c) n))
-> StyledPlot b (BaseSpace c) n -> f (StyledPlot b (BaseSpace c) n)
forall (f :: * -> *) a b.
HasPlotOptions f a b =>
LensLike' f a (PlotOptions b (V a) (N a))
plotOptions

instance Settable f => HasPlotStyle f (Axis b c n) b where
  plotStyle :: LensLike'
  f (Axis b c n) (PlotStyle b (V (Axis b c n)) (N (Axis b c n)))
plotStyle = (StyledPlot b (BaseSpace c) n -> f (StyledPlot b (BaseSpace c) n))
-> Axis b c n -> f (Axis b c n)
forall (c :: * -> *) (v :: * -> *) b n.
(BaseSpace c ~ v) =>
Setter' (Axis b c n) (StyledPlot b v n)
finalPlots ((StyledPlot b (BaseSpace c) n -> f (StyledPlot b (BaseSpace c) n))
 -> Axis b c n -> f (Axis b c n))
-> ((PlotStyle b (BaseSpace c) n
     -> f (PlotStyle b (BaseSpace c) n))
    -> StyledPlot b (BaseSpace c) n
    -> f (StyledPlot b (BaseSpace c) n))
-> (PlotStyle b (BaseSpace c) n -> f (PlotStyle b (BaseSpace c) n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PlotStyle b (BaseSpace c) n -> f (PlotStyle b (BaseSpace c) n))
-> StyledPlot b (BaseSpace c) n -> f (StyledPlot b (BaseSpace c) n)
forall (f :: * -> *) a b.
HasPlotStyle f a b =>
LensLike' f a (PlotStyle b (V a) (N a))
plotStyle

instance HasLegend (Axis b c n) b where
  legend :: Lens' (Axis b c n) (Legend b (N (Axis b c n)))
legend = (Axis b c n -> Legend b n)
-> (Axis b c n -> Legend b n -> Axis b c n)
-> Lens (Axis b c n) (Axis b c n) (Legend b n) (Legend b n)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Axis b c n -> Legend b n
forall b (c :: * -> *) n. Axis b c n -> Legend b n
_legend (\Axis b c n
a Legend b n
l -> Axis b c n
a {_legend :: Legend b n
_legend = Legend b n
l})

instance HasTitle (Axis b c n) b where
  title :: Lens' (Axis b c n) (Title b (V (Axis b c n)) (N (Axis b c n)))
title = (Axis b c n -> Title b (BaseSpace c) n)
-> (Axis b c n -> Title b (BaseSpace c) n -> Axis b c n)
-> Lens
     (Axis b c n)
     (Axis b c n)
     (Title b (BaseSpace c) n)
     (Title b (BaseSpace c) n)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Axis b c n -> Title b (BaseSpace c) n
forall b (c :: * -> *) n. Axis b c n -> Title b (BaseSpace c) n
_axisTitle (\Axis b c n
a Title b (BaseSpace c) n
t -> Axis b c n
a {_axisTitle :: Title b (BaseSpace c) n
_axisTitle = Title b (BaseSpace c) n
t})

-- | The size used for the rendered axis.
axisSize :: (HasLinearMap c, Num n, Ord n) => Lens' (Axis b c n) (SizeSpec c n)
axisSize :: forall (c :: * -> *) n b.
(HasLinearMap c, Num n, Ord n) =>
Lens' (Axis b c n) (SizeSpec c n)
axisSize = (c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> Axis b c n -> f (Axis b c n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes ((c (SingleAxis b (BaseSpace c) n)
  -> f (c (SingleAxis b (BaseSpace c) n)))
 -> Axis b c n -> f (Axis b c n))
-> ((SizeSpec c n -> f (SizeSpec c n))
    -> c (SingleAxis b (BaseSpace c) n)
    -> f (c (SingleAxis b (BaseSpace c) n)))
-> (SizeSpec c n -> f (SizeSpec c n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
  (Context (Maybe n) (Maybe n))
  (SingleAxis b (BaseSpace c) n)
  (SingleAxis b (BaseSpace c) n)
  (Maybe n)
  (Maybe n)
-> Lens
     (c (SingleAxis b (BaseSpace c) n))
     (c (SingleAxis b (BaseSpace c) n))
     (c (Maybe n))
     (c (Maybe n))
forall (f :: * -> *) a b s t.
Representable f =>
LensLike (Context a b) s t a b -> Lens (f s) (f t) (f a) (f b)
column LensLike
  (Context (Maybe n) (Maybe n))
  (SingleAxis b (BaseSpace c) n)
  (SingleAxis b (BaseSpace c) n)
  (Maybe n)
  (Maybe n)
forall (f :: * -> *) a.
(HasAxisScaling f a, Functor f) =>
LensLike' f a (Maybe (N a))
renderSize ((c (Maybe n) -> f (c (Maybe n)))
 -> c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> ((SizeSpec c n -> f (SizeSpec c n))
    -> c (Maybe n) -> f (c (Maybe n)))
-> (SizeSpec c n -> f (SizeSpec c n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (c (Maybe n) -> SizeSpec c n)
-> (SizeSpec c n -> c (Maybe n))
-> Iso (c (Maybe n)) (c (Maybe n)) (SizeSpec c n) (SizeSpec c n)
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso c (Maybe n) -> SizeSpec c n
forall (v :: * -> *) n.
(Functor v, Num n) =>
v (Maybe n) -> SizeSpec v n
mkSizeSpec SizeSpec c n -> c (Maybe n)
forall (v :: * -> *) n.
(Functor v, Num n, Ord n) =>
SizeSpec v n -> v (Maybe n)
getSpec -- column axisScaling . asSizeSpec -- iso mkSizeSpec getSpec

-- | The range used for the colour bar limits. This is automatically set
--   when using 'heatMap' or 'heatMap''
colourBarRange :: Lens' (Axis b v n) (n,n)
colourBarRange :: forall b (v :: * -> *) n. Lens' (Axis b v n) (n, n)
colourBarRange = (Axis b v n -> (n, n))
-> (Axis b v n -> (n, n) -> Axis b v n)
-> Lens (Axis b v n) (Axis b v n) (n, n) (n, n)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Axis b v n -> (n, n)
forall b (c :: * -> *) n. Axis b c n -> (n, n)
_colourBarR (\Axis b v n
a (n, n)
r -> Axis b v n
a {_colourBarR :: (n, n)
_colourBarR = (n, n)
r})

instance HasAxisStyle (Axis b v n) b where
  axisStyle :: Lens' (Axis b v n) (AxisStyle b (V (Axis b v n)) (N (Axis b v n)))
axisStyle = (Axis b v n -> AxisStyle b (BaseSpace v) n)
-> (Axis b v n -> AxisStyle b (BaseSpace v) n -> Axis b v n)
-> Lens
     (Axis b v n)
     (Axis b v n)
     (AxisStyle b (BaseSpace v) n)
     (AxisStyle b (BaseSpace v) n)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Axis b v n -> AxisStyle b (BaseSpace v) n
forall b (c :: * -> *) n. Axis b c n -> AxisStyle b (BaseSpace c) n
_axisStyle (\Axis b v n
a AxisStyle b (BaseSpace v) n
sty -> Axis b v n
a {_axisStyle :: AxisStyle b (BaseSpace v) n
_axisStyle = AxisStyle b (BaseSpace v) n
sty})

instance HasColourBar (Axis b v n) b where
  colourBar :: Lens' (Axis b v n) (ColourBar b (N (Axis b v n)))
colourBar = (Axis b v n -> ColourBar b n)
-> (Axis b v n -> ColourBar b n -> Axis b v n)
-> Lens (Axis b v n) (Axis b v n) (ColourBar b n) (ColourBar b n)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Axis b v n -> ColourBar b n
forall b (c :: * -> *) n. Axis b c n -> ColourBar b n
_colourBar (\Axis b v n
a ColourBar b n
cb -> Axis b v n
a {_colourBar :: ColourBar b n
_colourBar = ColourBar b n
cb})

-- Axis functions ------------------------------------------------------

-- $plotable
-- The 'Plotable' class defines ways of converting the data type to a
-- diagram for some axis. There are several variants for adding an axis
-- with constraints @('InSpace' v n a, 'Plotable' a b)@:
--
-- @
-- 'addPlotable'  ::           a -> 'PlotState' a b -> 'AxisState' b v n
-- 'addPlotable''   ::           a ->                  'AxisState' b v n
-- @
--
-- The last argument is a 'PlotState' so you can use @do@ notation to
-- make adjustments to the plot. The @L@ suffix stands for \"legend\",
-- it is equivalent of using 'addLegendEntry' in the 'PlotState'. Since
-- legend entries are so common it has it's own suffix. The following
-- are equivalent:
--
-- @
-- myaxis = 'r2Axis' &~ do
--   'addPlotable'' myplot $ do
--     'addLegendEntry' "my plot"
-- @
--
-- Most of the time you won't use these functions directly. However,
-- other plotting functions follow this naming convention where instead
-- of @a@, it takes the data needed to make the plot.

-- | Add a 'Plotable' 'Plot' to an 'Axis'.
addPlot
  :: (InSpace (BaseSpace c) n p, MonadState (Axis b c n) m, Plotable p b)
  => Plot p b -- ^ the plot
  -> m ()     -- ^ add plot to the 'Axis'
addPlot :: forall (c :: * -> *) n p b (m :: * -> *).
(InSpace (BaseSpace c) n p, MonadState (Axis b c n) m,
 Plotable p b) =>
Plot p b -> m ()
addPlot Plot p b
p = ([DynamicPlot b (BaseSpace c) n]
 -> Identity [DynamicPlot b (BaseSpace c) n])
-> Axis b c n -> Identity (Axis b c n)
forall (c :: * -> *) (v :: * -> *) b n.
(BaseSpace c ~ v) =>
Lens' (Axis b c n) [DynamicPlot b v n]
axisPlots (([DynamicPlot b (BaseSpace c) n]
  -> Identity [DynamicPlot b (BaseSpace c) n])
 -> Axis b c n -> Identity (Axis b c n))
-> [DynamicPlot b (BaseSpace c) n] -> m ()
forall s (m :: * -> *) a.
(MonadState s m, Semigroup a) =>
ASetter' s a -> a -> m ()
<>= [Plot p b -> DynamicPlot b (BaseSpace c) n
forall (v :: * -> *) n p b.
(InSpace v n p, Plotable p b) =>
Plot p b -> DynamicPlot b v n
DynamicPlot Plot p b
p]

-- | Add something 'Plotable' to the 'Axis' with a stateful modification
--   of the 'Plot'.
addPlotable
  :: (InSpace (BaseSpace c) n p, MonadState (Axis b c n) m, Plotable p b)
  => p -- ^ the raw plot
  -> State (Plot p b) () -- ^ changes to the plot
  -> m () -- ^ add plot to the 'Axis'
addPlotable :: forall (c :: * -> *) n p b (m :: * -> *).
(InSpace (BaseSpace c) n p, MonadState (Axis b c n) m,
 Plotable p b) =>
p -> State (Plot p b) () -> m ()
addPlotable p
p State (Plot p b) ()
s = Plot p b -> m ()
forall (c :: * -> *) n p b (m :: * -> *).
(InSpace (BaseSpace c) n p, MonadState (Axis b c n) m,
 Plotable p b) =>
Plot p b -> m ()
addPlot (Plot p b -> m ()) -> Plot p b -> m ()
forall a b. (a -> b) -> a -> b
$ State (Plot p b) () -> Plot p b -> Plot p b
forall s a. State s a -> s -> s
execState State (Plot p b) ()
s (p -> Plot p b
forall p b. (Additive (V p), Num (N p)) => p -> Plot p b
mkPlot p
p)

-- | Simple version of 'AddPlotable' without any changes 'Plot'.
addPlotable'
  :: (InSpace (BaseSpace v) n p, MonadState (Axis b v n) m, Plotable p b)
  => p    -- ^ the raw plot
  -> m () -- ^ add plot to the 'Axis'
addPlotable' :: forall (v :: * -> *) n p b (m :: * -> *).
(InSpace (BaseSpace v) n p, MonadState (Axis b v n) m,
 Plotable p b) =>
p -> m ()
addPlotable' p
p = p -> State (Plot p b) () -> m ()
forall (c :: * -> *) n p b (m :: * -> *).
(InSpace (BaseSpace c) n p, MonadState (Axis b c n) m,
 Plotable p b) =>
p -> State (Plot p b) () -> m ()
addPlotable p
p (() -> State (Plot p b) ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())

------------------------------------------------------------------------
-- Predefined axes
------------------------------------------------------------------------

-- | The default axis for plots in the 'V2' coordinate system.
r2Axis
  :: (TypeableFloat n,
     Renderable (Text n) b,
     Renderable (Path V2 n) b)
  => Axis b V2 n
r2Axis :: forall n b.
(TypeableFloat n, Renderable (Text n) b,
 Renderable (Path V2 n) b) =>
Axis b V2 n
r2Axis = Axis
  { _axisStyle :: AxisStyle b (BaseSpace V2) n
_axisStyle  = AxisStyle b (BaseSpace V2) n
forall n b.
(TypeableFloat n, Renderable (Path V2 n) b) =>
AxisStyle b V2 n
fadedColours
  , _colourBar :: ColourBar b n
_colourBar  = ColourBar b n
forall n b.
(Renderable (Text n) b, Renderable (Path V2 n) b,
 TypeableFloat n) =>
ColourBar b n
defColourBar
  , _colourBarR :: (n, n)
_colourBarR = (n
0,n
1)
  , _axisTitle :: Title b (BaseSpace V2) n
_axisTitle  = Title b (BaseSpace V2) n
forall a. Default a => a
def

  , _legend :: Legend b n
_legend       = Legend b n
forall a. Default a => a
def
  , _axisPlots :: [DynamicPlot b (BaseSpace V2) n]
_axisPlots    = []
  , _plotModifier :: Endo (StyledPlot b (BaseSpace V2) n)
_plotModifier = Endo (StyledPlot b (BaseSpace V2) n)
forall a. Monoid a => a
mempty

  , _axes :: V2 (SingleAxis b (BaseSpace V2) n)
_axes = SingleAxis b V2 n -> V2 (SingleAxis b V2 n)
forall (f :: * -> *) a. Applicative f => a -> f a
pure SingleAxis b V2 n
forall a. Default a => a
def
  }

-- The x-axis ----------------------------------------------------------

-- | Lens onto the x-axis of an 'Axis'.
xAxis :: R1 c => Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
xAxis :: forall (c :: * -> *) b n.
R1 c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
xAxis = (c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> Axis b c n -> f (Axis b c n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes ((c (SingleAxis b (BaseSpace c) n)
  -> f (c (SingleAxis b (BaseSpace c) n)))
 -> Axis b c n -> f (Axis b c n))
-> ((SingleAxis b (BaseSpace c) n
     -> f (SingleAxis b (BaseSpace c) n))
    -> c (SingleAxis b (BaseSpace c) n)
    -> f (c (SingleAxis b (BaseSpace c) n)))
-> (SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall (t :: * -> *) a. R1 t => Lens' (t a) a
_x

-- | The label for the x-axis. Shorthand for @'xAxis' . 'axisLabelText'@.
xLabel :: R1 c => Lens' (Axis b c n) String
xLabel :: forall (c :: * -> *) b n. R1 c => Lens' (Axis b c n) String
xLabel = (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n -> f (Axis b c n)
forall (c :: * -> *) b n.
R1 c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
xAxis ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> Axis b c n -> f (Axis b c n))
-> ((String -> f String)
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (String -> f String)
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> f String)
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a String
axisLabelText

-- | The minimum x value for the axis. If the value if 'Nothing' (the
--   'Default'), the bounds will be infered by the plots in the axis.
xMin :: R1 c => Lens' (Axis b c n) (Maybe n)
xMin :: forall (c :: * -> *) b n. R1 c => Lens' (Axis b c n) (Maybe n)
xMin = (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n -> f (Axis b c n)
forall (c :: * -> *) b n.
R1 c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
xAxis ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> Axis b c n -> f (Axis b c n))
-> ((Maybe n -> f (Maybe n))
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (Maybe n -> f (Maybe n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe n -> f (Maybe n))
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a.
(HasAxisScaling f a, Functor f) =>
LensLike' f a (Maybe (N a))
boundMin

-- | The minimum x value for the axis. If the value if 'Nothing' (the
--   'Default'), the bounds will be infered by the plots in the axis.
xMax :: R1 c => Lens' (Axis b c n) (Maybe n)
xMax :: forall (c :: * -> *) b n. R1 c => Lens' (Axis b c n) (Maybe n)
xMax = (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n -> f (Axis b c n)
forall (c :: * -> *) b n.
R1 c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
xAxis ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> Axis b c n -> f (Axis b c n))
-> ((Maybe n -> f (Maybe n))
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (Maybe n -> f (Maybe n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe n -> f (Maybe n))
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a.
(HasAxisScaling f a, Functor f) =>
LensLike' f a (Maybe (N a))
boundMax

-- The y-axis ----------------------------------------------------------

-- | Lens onto the y-axis of an 'Axis'.
yAxis :: R2 c => Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
yAxis :: forall (c :: * -> *) b n.
R2 c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
yAxis = (c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> Axis b c n -> f (Axis b c n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes ((c (SingleAxis b (BaseSpace c) n)
  -> f (c (SingleAxis b (BaseSpace c) n)))
 -> Axis b c n -> f (Axis b c n))
-> ((SingleAxis b (BaseSpace c) n
     -> f (SingleAxis b (BaseSpace c) n))
    -> c (SingleAxis b (BaseSpace c) n)
    -> f (c (SingleAxis b (BaseSpace c) n)))
-> (SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall (t :: * -> *) a. R2 t => Lens' (t a) a
_y

-- | The label for the y-axis. Shorthand for @'yAxis' . 'axisLabelText'@.
yLabel :: R2 c => Lens' (Axis b c n) String
yLabel :: forall (c :: * -> *) b n. R2 c => Lens' (Axis b c n) String
yLabel = (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n -> f (Axis b c n)
forall (c :: * -> *) b n.
R2 c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
yAxis ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> Axis b c n -> f (Axis b c n))
-> ((String -> f String)
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (String -> f String)
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> f String)
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a String
axisLabelText

-- | The minimum y value for the axis. If the value if 'Nothing' (the
--   'Default'), the bounds will be infered by the plots in the axis.
yMin :: R2 c => Lens' (Axis b c n) (Maybe n)
yMin :: forall (c :: * -> *) b n. R2 c => Lens' (Axis b c n) (Maybe n)
yMin = (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n -> f (Axis b c n)
forall (c :: * -> *) b n.
R2 c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
yAxis ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> Axis b c n -> f (Axis b c n))
-> ((Maybe n -> f (Maybe n))
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (Maybe n -> f (Maybe n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe n -> f (Maybe n))
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a.
(HasAxisScaling f a, Functor f) =>
LensLike' f a (Maybe (N a))
boundMin

-- | The minimum y value for the axis. If the value if 'Nothing' (the
--   'Default'), the bounds will be infered by the plots in the axis.
yMax :: R2 c => Lens' (Axis b c n) (Maybe n)
yMax :: forall (c :: * -> *) b n. R2 c => Lens' (Axis b c n) (Maybe n)
yMax = (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n -> f (Axis b c n)
forall (c :: * -> *) b n.
R2 c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
yAxis ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> Axis b c n -> f (Axis b c n))
-> ((Maybe n -> f (Maybe n))
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (Maybe n -> f (Maybe n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe n -> f (Maybe n))
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a.
(HasAxisScaling f a, Functor f) =>
LensLike' f a (Maybe (N a))
boundMax

-- The z-axis ----------------------------------------------------------

-- | Lens onto the z-axis of an 'Axis'.
zAxis :: R3 c => Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
zAxis :: forall (c :: * -> *) b n.
R3 c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
zAxis = (c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> Axis b c n -> f (Axis b c n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes ((c (SingleAxis b (BaseSpace c) n)
  -> f (c (SingleAxis b (BaseSpace c) n)))
 -> Axis b c n -> f (Axis b c n))
-> ((SingleAxis b (BaseSpace c) n
     -> f (SingleAxis b (BaseSpace c) n))
    -> c (SingleAxis b (BaseSpace c) n)
    -> f (c (SingleAxis b (BaseSpace c) n)))
-> (SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall (t :: * -> *) a. R3 t => Lens' (t a) a
_z

-- | The label for the z-axis. Shorthand for @'zAxis' . 'axisLabelText'@.
zLabel :: R3 c => Lens' (Axis b c n) String
zLabel :: forall (c :: * -> *) b n. R3 c => Lens' (Axis b c n) String
zLabel = (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n -> f (Axis b c n)
forall (c :: * -> *) b n.
R3 c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
zAxis ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> Axis b c n -> f (Axis b c n))
-> ((String -> f String)
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (String -> f String)
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> f String)
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a String
axisLabelText

-- | The minimum z value for the axis. If the value if 'Nothing' (the
--   'Default'), the bounds will be infered by the plots in the axis.
zMin :: R3 c => Lens' (Axis b c n) (Maybe n)
zMin :: forall (c :: * -> *) b n. R3 c => Lens' (Axis b c n) (Maybe n)
zMin = (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n -> f (Axis b c n)
forall (c :: * -> *) b n.
R3 c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
zAxis ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> Axis b c n -> f (Axis b c n))
-> ((Maybe n -> f (Maybe n))
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (Maybe n -> f (Maybe n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe n -> f (Maybe n))
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a.
(HasAxisScaling f a, Functor f) =>
LensLike' f a (Maybe (N a))
boundMin

-- | The minimum z value for the axis. If the value if 'Nothing' (the
--   'Default'), the bounds will be infered by the plots in the axis.
zMax :: R3 c => Lens' (Axis b c n) (Maybe n)
zMax :: forall (c :: * -> *) b n. R3 c => Lens' (Axis b c n) (Maybe n)
zMax = (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n -> f (Axis b c n)
forall (c :: * -> *) b n.
R3 c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
zAxis ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> Axis b c n -> f (Axis b c n))
-> ((Maybe n -> f (Maybe n))
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (Maybe n -> f (Maybe n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe n -> f (Maybe n))
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a.
(HasAxisScaling f a, Functor f) =>
LensLike' f a (Maybe (N a))
boundMax

-- The r-axis ----------------------------------------------------------

-- | Lens onto the radial axis of an 'Axis'.
rAxis :: Radial c => Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
rAxis :: forall (c :: * -> *) b n.
Radial c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
rAxis = (c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> Axis b c n -> f (Axis b c n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes ((c (SingleAxis b (BaseSpace c) n)
  -> f (c (SingleAxis b (BaseSpace c) n)))
 -> Axis b c n -> f (Axis b c n))
-> ((SingleAxis b (BaseSpace c) n
     -> f (SingleAxis b (BaseSpace c) n))
    -> c (SingleAxis b (BaseSpace c) n)
    -> f (c (SingleAxis b (BaseSpace c) n)))
-> (SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> c (SingleAxis b (BaseSpace c) n)
-> f (c (SingleAxis b (BaseSpace c) n))
forall (t :: * -> *) a. Radial t => Lens' (t a) a
_radial

-- | The label for the radial axis. Shorthand for @'rAxis' . 'axisLabelText'@.
rLabel :: Radial c => Lens' (Axis b c n) String
rLabel :: forall (c :: * -> *) b n. Radial c => Lens' (Axis b c n) String
rLabel = (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n -> f (Axis b c n)
forall (c :: * -> *) b n.
Radial c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
rAxis ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> Axis b c n -> f (Axis b c n))
-> ((String -> f String)
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (String -> f String)
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> f String)
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a String
axisLabelText

-- | The minimum z value for the axis. If the value if 'Nothing' (the
--   'Default'), the bounds will be infered by the plots in the axis.
-- rMin :: R3 c => Lens' (Axis b c n) (Maybe n)
-- rMin = zAxis . boundMin

-- | The minimum radial value for the axis. If the value if 'Nothing'
--   (the 'Default'), the bounds will be infered by the plots in the
--   axis.
rMax :: Radial c => Lens' (Axis b c n) (Maybe n)
rMax :: forall (c :: * -> *) b n. Radial c => Lens' (Axis b c n) (Maybe n)
rMax = (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n -> f (Axis b c n)
forall (c :: * -> *) b n.
Radial c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
rAxis ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> Axis b c n -> f (Axis b c n))
-> ((Maybe n -> f (Maybe n))
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (Maybe n -> f (Maybe n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe n -> f (Maybe n))
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a.
(HasAxisScaling f a, Functor f) =>
LensLike' f a (Maybe (N a))
boundMax

-- The theta-axis ------------------------------------------------------

-- | Lens onto the radial axis of an 'Axis'.
thetaAxis :: Circle c => Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
thetaAxis :: forall (c :: * -> *) b n.
Circle c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
thetaAxis = (c (SingleAxis b (BaseSpace c) n)
 -> f (c (SingleAxis b (BaseSpace c) n)))
-> Axis b c n -> f (Axis b c n)
forall (v :: * -> *) (c :: * -> *) (c' :: * -> *) b n.
(v ~ BaseSpace c, v ~ BaseSpace c') =>
Lens
  (Axis b c n)
  (Axis b c' n)
  (c (SingleAxis b v n))
  (c' (SingleAxis b v n))
axes ((c (SingleAxis b (BaseSpace c) n)
  -> f (c (SingleAxis b (BaseSpace c) n)))
 -> Axis b c n -> f (Axis b c n))
-> ((SingleAxis b (BaseSpace c) n
     -> f (SingleAxis b (BaseSpace c) n))
    -> c (SingleAxis b (BaseSpace c) n)
    -> f (c (SingleAxis b (BaseSpace c) n)))
-> (SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. E c -> forall x. Lens' (c x) x
forall (t :: * -> *). E t -> forall x. Lens' (t x) x
el E c
forall (v :: * -> *). Circle v => E v
etheta

-- | The label for the radial axis. Shorthand for @'rAxis' . 'axisLabelText'@.
thetaLabel :: Circle c => Lens' (Axis b c n) String
thetaLabel :: forall (c :: * -> *) b n. Circle c => Lens' (Axis b c n) String
thetaLabel = (SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
-> Axis b c n -> f (Axis b c n)
forall (c :: * -> *) b n.
Circle c =>
Lens' (Axis b c n) (SingleAxis b (BaseSpace c) n)
thetaAxis ((SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n))
 -> Axis b c n -> f (Axis b c n))
-> ((String -> f String)
    -> SingleAxis b (BaseSpace c) n
    -> f (SingleAxis b (BaseSpace c) n))
-> (String -> f String)
-> Axis b c n
-> f (Axis b c n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> f String)
-> SingleAxis b (BaseSpace c) n -> f (SingleAxis b (BaseSpace c) n)
forall (f :: * -> *) a b.
(HasAxisLabel f a b, Functor f) =>
LensLike' f a String
axisLabelText


-- R3 Axis

-- instance (TypeableFloat n, Enum n, Renderable (Text n) b, Renderable (Path V2 n) b)
--     => Default (Axis b V3 n) where
--   def = Axis
--           { _axisTitle      = Nothing
--           , _axisSize       = mkWidth 300
--           , _axisPlots      = []
--           , _axisLegend     = def
--           , _axisTheme      = coolTheme
--           , _axisLinearMap  = isometricProjection
--           , _axisAxisBounds = Bounds $ pure def
--           , _axisGridLines  = pure def
--           , _axisLabels     = pure def
--           , _axisScaling    = pure def
--           , _axisTickLabels = pure def
--           , _axisTicks      = pure def
--           , _axisLines      = pure def
--           }

-- R3 Axis

polarAxis
  :: (TypeableFloat n,
      Renderable (Text n) b,
      Renderable (Path V2 n) b)
  => Axis b Polar n
polarAxis :: forall n b.
(TypeableFloat n, Renderable (Text n) b,
 Renderable (Path V2 n) b) =>
Axis b Polar n
polarAxis = Axis
  { _axisStyle :: AxisStyle b (BaseSpace Polar) n
_axisStyle  = AxisStyle b (BaseSpace Polar) n
forall n b.
(TypeableFloat n, Renderable (Path V2 n) b) =>
AxisStyle b V2 n
fadedColours
  , _colourBar :: ColourBar b n
_colourBar  = ColourBar b n
forall n b.
(Renderable (Text n) b, Renderable (Path V2 n) b,
 TypeableFloat n) =>
ColourBar b n
defColourBar
  , _colourBarR :: (n, n)
_colourBarR = (n
0,n
1)
  , _axisTitle :: Title b (BaseSpace Polar) n
_axisTitle  = Title b (BaseSpace Polar) n
forall a. Default a => a
def

  , _legend :: Legend b n
_legend       = Legend b n
forall a. Default a => a
def
  , _axisPlots :: [DynamicPlot b (BaseSpace Polar) n]
_axisPlots    = []
  , _plotModifier :: Endo (StyledPlot b (BaseSpace Polar) n)
_plotModifier = Endo (StyledPlot b (BaseSpace Polar) n)
forall a. Monoid a => a
mempty

  , _axes :: Polar (SingleAxis b (BaseSpace Polar) n)
_axes = SingleAxis b V2 n -> Polar (SingleAxis b V2 n)
forall (f :: * -> *) a. Applicative f => a -> f a
pure SingleAxis b V2 n
forall a. Default a => a
def
  }