Skip to content

Commit

Permalink
fix all errors reported when building docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bjarthur committed Apr 27, 2018
1 parent e754614 commit abc477e
Show file tree
Hide file tree
Showing 21 changed files with 140 additions and 79 deletions.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ makedocs(
"Shapes" => "gallery/shapes.md",
],
"Library" => Any[
"Gadfly" => "lib/gadfly.md",
"Geometries" => "lib/geometries.md",
"Guides" => "lib/guides.md",
"Statistics" => "lib/statistics.md",
Expand Down
14 changes: 7 additions & 7 deletions docs/src/dev/pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ The specification of each layer has

All layers of a plot share the same

- [Coordinates](@ref) for the geometry (e.g. cartesian, polar, etc.)
- axis [Scales](@ref) (e.g. loglog, semilog, etc.)
- plot-wise [Statistics](@ref) (optional) to be applied to all layers
- [Guides](@ref)
- [Coordinates](@ref lib_coord) for the geometry (e.g. cartesian, polar, etc.)
- axis [Scales](@ref lib_scale) (e.g. loglog, semilog, etc.)
- plot-wise [Statistics](@ref lib_stat) (optional) to be applied to all layers
- [Guides](@ref lib_guide)

A full plot specification must describe these shared elements as well as all the layer specifications.
In the example above, we see that only the data source, statistics, geometry, and mapping are specified.
Expand All @@ -75,11 +75,11 @@ Once a full plot specification is filled out, the rendering process proceeds as

1. For each layer in the plot, we first map subsets of the data source to a `Data` object. The `Price` and `Cut` columns of the `diamond` dataset are mapped to the `:x` and `:color` fields of `Data`, respectively.

2. Scales are applied to the data to obtain plottable aesthetics. [Scale.x_continuous](@ref) keeps the values of `df[:Price]` unchanged, while [Scale.color_discrete_hue](@ref) maps the unique elements of `df[:Cut]` (an array of strings) to actual color values.
2. Scales are applied to the data to obtain plottable aesthetics. [`Scale.x_continuous`](@ref) keeps the values of `df[:Price]` unchanged, while [`Scale.color_discrete_hue`](@ref) maps the unique elements of `df[:Cut]` (an array of strings) to actual color values.

3. The aesthetics are transformed by layer-wise and plot-wise statistics, in order. [Stat.histogram](@ref) replaces the `x` field of the aesthetics with bin positions, and sets the `y` field with the corresponding counts.
3. The aesthetics are transformed by layer-wise and plot-wise statistics, in order. [`Stat.histogram`](@ref) replaces the `x` field of the aesthetics with bin positions, and sets the `y` field with the corresponding counts.

4. Using the position aesthetics from all layers, we create a Compose context with a coordinate system that fits the data to screen coordinates. [Coord.cartesian](@ref) creates a Compose context that maps a vertical distance of `3000` counts to about two inches in the rendered plot.
4. Using the position aesthetics from all layers, we create a Compose context with a coordinate system that fits the data to screen coordinates. [`Coord.cartesian`](@ref) creates a Compose context that maps a vertical distance of `3000` counts to about two inches in the rendered plot.

5. Each layer renders its own geometry.

Expand Down
5 changes: 3 additions & 2 deletions docs/src/gallery/scales.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ plot(x=rand(12), y=rand(12), color=repeat([1,2,3], outer=[4]),

!!! note

To set a default color scale for plots, you can set it in the current
[Theme](@ref) using `push_theme`, using `style` to modify the current theme.
To set a default color scale for plots, you can set it in the current Theme
(see [Themes](@ref)) using `push_theme`, using `style` to modify the
current theme.

```
Gadfly.push_theme(style(discrete_color_scale=Scale.color_discrete(gen_colors)))
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/coordinates.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Author = "Tamas Nagy"
```

# Coordinates
# [Coordinates](@id lib_coord)

Coordinate systems are mappings between a coordinate space and the 2D rendered output.

Expand Down
9 changes: 9 additions & 0 deletions docs/src/lib/gadfly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
```@meta
Author = "Ben J. Arthur"
```

# Gadfly

```@autodocs
Modules = [Gadfly]
```
2 changes: 1 addition & 1 deletion docs/src/lib/geometries.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Author = "Daniel C. Jones"
```

# Geometries
# [Geometries](@id lib_geom)

Geometries are responsible for actually doing the drawing. A geometry takes
as input one or more aesthetics, and used data bound to these aesthetics to
Expand Down
4 changes: 2 additions & 2 deletions docs/src/lib/guides.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Author = "Daniel C. Jones"
```

# Guides
# [Guides](@id lib_guide)

Very similar to [Geometries](@ref) are guides, which draw graphics supporting the
Very similar to Geometries are guides, which draw graphics supporting the
actual visualization, such as axis ticks and labels and color keys. The major
distinction is that geometries always draw within the rectangular plot frame,
while guides have some special layout considerations.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/lib/scales.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Author = "Daniel C. Jones"
```

# Scales
# [Scales](@id lib_scale)

Scales, similarly to [Statistics](@ref), apply a transformation to the original
Scales, similarly to Statistics, apply a transformation to the original
data, typically mapping one aesthetic to the same aesthetic, while retaining
the original value. For example, the Scale.x_log10 aesthetic maps the
`x` aesthetic back to the `x` aesthetic after applying a log10 transformation,
Expand Down
4 changes: 2 additions & 2 deletions docs/src/lib/statistics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
Author = "Daniel C. Jones"
```

# Statistics
# [Statistics](@id lib_stat)

Statistics are functions taking as input one or more aesthetics, operating on
those values, then output to one or more aesthetics. For example, drawing of
boxplots typically uses the boxplot statistic ([Stat.boxplot](@ref)) that takes
boxplots typically uses the boxplot statistic ([`Stat.boxplot`](@ref)) that takes
as input the `x` and `y` aesthetic, and outputs the middle, and upper and lower
hinge, and upper and lower fence aesthetics.

Expand Down
11 changes: 6 additions & 5 deletions docs/src/man/plotting.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ Author = "Daniel C. Jones"

# Plotting

Most interaction with Gadfly is through the `plot` function. Plots are described
by binding data to **aesthetics**, and specifying a number of plot elements
including [Scales](@ref), [Coordinates](@ref), [Guides](@ref), and [Geometries](@ref).
Aesthetics are a set of special named variables that are mapped to plot
geometry. How this mapping occurs is defined by the plot elements.
Most interaction with Gadfly is through the `plot` function. Plots are
described by binding data to **aesthetics**, and specifying a number of plot
elements including [Scales](@ref lib_scale), [Coordinates](@ref lib_coord),
[Guides](@ref lib_guide), and [Geometries](@ref lib_geom). Aesthetics are a
set of special named variables that are mapped to plot geometry. How this
mapping occurs is defined by the plot elements.

This "grammar of graphics" approach tries to avoid arcane incantations and
special cases, instead approaching the problem as if one were drawing a wiring
Expand Down
35 changes: 15 additions & 20 deletions src/Gadfly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,17 @@ const gadflyjs = joinpath(dirname(Base.source_path()), "gadfly.js")
# Set prefereed canvas size when rendering a plot without an explicit call to
# `draw`.
"""
```
set_default_plot_size(width::Compose.MeasureOrNumber, height::Compose.MeasureOrNumber)
```
set_default_plot_size(width::Compose.MeasureOrNumber, height::Compose.MeasureOrNumber)
Sets preferred canvas size when rendering a plot without an explicit call to draw
"""
set_default_plot_size(width::Compose.MeasureOrNumber, height::Compose.MeasureOrNumber) =
Compose.set_default_graphic_size(width, height)


"""
```
set_default_plot_format(fmt::Symbol)
```
set_default_plot_format(fmt::Symbol)
Sets the default plot format
"""
set_default_plot_format(fmt::Symbol) = Compose.set_default_graphic_format(fmt)
Expand All @@ -135,10 +133,9 @@ copy(l::Layer) = Layer(l)


"""
```
layer(data_source::@compat(Union{AbstractDataFrame, (@compat Void)}),
elements::ElementOrFunction...; mapping...)
```
layer(data_source::@compat(Union{AbstractDataFrame, (@compat Void)}),
elements::ElementOrFunction...; mapping...)
Creates layers based on elements
### Args
Expand Down Expand Up @@ -273,8 +270,8 @@ const ElementOrFunctionOrLayers = Union{ElementOrFunction, Vector{Layer}}

"""
```
function plot(data_source::@compat(Union{AbstractMatrix, AbstractDataFrame}),
elements::ElementOrFunctionOrLayers...; mapping...)
plot(data_source::@compat(Union{AbstractMatrix, AbstractDataFrame}),
elements::ElementOrFunctionOrLayers...; mapping...)
```
Create a new plot.
Expand Down Expand Up @@ -322,10 +319,9 @@ end
# A Plot object.
#
"""
```
function plot(data_source::@compat(Union{(@compat Void), AbstractMatrix, AbstractDataFrame}),
mapping::Dict, elements::ElementOrFunctionOrLayers...)
```
plot(data_source::@compat(Union{(@compat Void), AbstractMatrix, AbstractDataFrame}),
mapping::Dict, elements::ElementOrFunctionOrLayers...)
The old fashioned (pre named arguments) version of plot.
This version takes an explicit mapping dictionary, mapping aesthetics symbols
Expand Down Expand Up @@ -856,9 +852,8 @@ end

# A convenience version of Compose.draw that let's you skip the call to render.
"""
```
draw(backend::Compose.Backend, p::Plot)
```
draw(backend::Compose.Backend, p::Plot)
A convenience version of Compose.draw without having to call render
### Args
Expand Down Expand Up @@ -935,9 +930,9 @@ gridstack([p1 p1; p1 p1])
gridstack(Union{Plot,Compose.Context}[p1 p2; p2 p1])
```
"""
_gridstack(ps::Matrix) = gridstack(map(p->typeof(p)==Plot ? render(p) : p, ps))
gridstack(ps::Matrix{Plot}) = _gridstack(ps)
gridstack(ps::Matrix{Union{Plot,Context}}) = _gridstack(ps)
_gridstack(ps::Matrix) = gridstack(map(p->typeof(p)==Plot ? render(p) : p, ps))

# show functions for all supported compose backends.

Expand Down
2 changes: 1 addition & 1 deletion src/geom/bar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const bar = BarGeometry
"""
Geom.histogram[(; position, orientation, bincount, minbincount, maxbincount, density)]
Draw histograms. An alias for [Geom.bar](@ref) with [Stat.histogram](@ref).
Draw histograms. An alias for [`Geom.bar`](@ref) with [`Stat.histogram`](@ref).
# Aesthetics
- `x`: Sample to draw histogram from.
Expand Down
2 changes: 1 addition & 1 deletion src/geom/boxplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Aesthetics used directly:
- `upper_fence`
- `outliers`
With default statistic [Stat.boxplot](@ref), only the following aesthetics need to be
With default statistic [`Stat.boxplot`](@ref), only the following aesthetics need to be
defined:
- `x` (optional): Group categorically on the X-axis.
Expand Down
4 changes: 2 additions & 2 deletions src/geom/hexbin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Bin data into tiled hexagonal bins and color by count.
- `xsize`
- `ysize`
By default [Stat.hexbin](@ref) is applied which bins `x` and `y` observations and
colors hexagons according to count. To override this, pass [Stat.identity](@ref) to
By default [`Stat.hexbin`](@ref) is applied which bins `x` and `y` observations and
colors hexagons according to count. To override this, pass [`Stat.identity`](@ref) to
`plot` and manually bind the `color` aesthetic.
# Arguments
Expand Down
20 changes: 10 additions & 10 deletions src/geom/line.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ end
Geom.path
Draw lines between points in the order they appear in the data. This is an
alias for [Geom.line](@ref) with `preserve_order=true`.
alias for [`Geom.line`](@ref) with `preserve_order=true`.
# Aesthetics
- `x`: X-axis position.
Expand All @@ -75,8 +75,8 @@ path() = LineGeometry(preserve_order=true)
"""
Geom.density[(; bandwidth)]
Draw a kernel density estimate from data. An alias for [Geom.line](@ref) with
[Stat.density](@ref).
Draw a kernel density estimate from data. An alias for [`Geom.line`](@ref) with
[`Stat.density`](@ref).
# Aesthetics
- `x`: Sample to draw density estimate from.
Expand All @@ -91,23 +91,23 @@ density(; bandwidth::Real=-Inf) =
"""
Geom.density2d[(; bandwidth, levels)]
Draw a kernel density estimate from data. An alias for [Geom.contour](@ref) with
[Stat.density2d](@ref).
Draw a kernel density estimate from data. An alias for [`Geom.contour`](@ref) with
[`Stat.density2d`](@ref).
# Aesthetics
- `x`, `y`: Sample to draw density estimate from.
# Arguments
- `bandwidth`: See [Geom.density](@ref).
- `levels`: See [Geom.contour](@ref).
- `bandwidth`: See [`Geom.density`](@ref).
- `levels`: See [`Geom.contour`](@ref).
"""
density2d(; bandwidth::Tuple{Real,Real}=(-Inf,-Inf), levels=15) =
LineGeometry(Gadfly.Stat.density2d(bandwidth=bandwidth, levels=levels); preserve_order=true)

"""
Geom.smooth[(; method, smoothing)]
Plot a smooth function estimated from data. An alias for [Geom.line](@ref) with [Stat.smooth](@ref).
Plot a smooth function estimated from data. An alias for [`Geom.line`](@ref) with [`Stat.smooth`](@ref).
# Aesthetics
- `x`: Predictor data.
Expand All @@ -127,8 +127,8 @@ smooth(; method::Symbol=:loess, smoothing::Float64=0.75) =
"""
Geom.step[(; direction)]
Connect points using a stepwise function. Equivalent to [Geom.line](@ref) with
[Stat.step](@ref).
Connect points using a stepwise function. Equivalent to [`Geom.line`](@ref) with
[`Stat.step`](@ref).
# Aesthetics
- `x`: Point x-coordinate.
Expand Down
2 changes: 1 addition & 1 deletion src/geom/rectbin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const rectbin = RectangularBinGeometry
Bin data in rectangles and indicate density with color. As in heatmaps, etc.
An alias for [Geom.rectbin](@ref) with [Stat.histogram2d](@ref).
An alias for [`Geom.rectbin`](@ref) with [`Stat.histogram2d`](@ref).
# Aesthetics
- `x`: Observations to be binned and plotted on the x coordinate.
Expand Down
2 changes: 1 addition & 1 deletion src/geom/subplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ or row of subplots is drawn, if both, a grid.
# Arguments
Unlike most geometries, [Geom.subplot_grid](@ref) is typically passed one or more
Unlike most geometries, [`Geom.subplot_grid`](@ref) is typically passed one or more
parameters. The constructor works for the most part like the `layer` function.
Arbitrary plot elements may be passed, while aesthetic bindings are inherited
from the parent plot.
Expand Down
2 changes: 1 addition & 1 deletion src/geom/violin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Aesthetics used directly:
- `width`: Density at a given `y` value.
- `color` (optional): Violin color. A suitable discrete variable is needed here. See example below.
With the default statistic [Stat.violin](@ref), only the following need be defined:
With the default statistic [`Stat.violin`](@ref), only the following need be defined:
- `x` (optional): Group categorically on the X-axis.
- `y`: Sample from which to draw the density plot.
Expand Down
6 changes: 2 additions & 4 deletions src/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,8 @@ function group_color_isless(a::(Tuple{S, T}),
end


"""
trim longer arrays to the size of the smallest one
and zip the arrays.
"""
#trim longer arrays to the size of the smallest one
#and zip the arrays.
function trim_zip(xs...)
mx = max(map(length, xs)...)
mn = min(map(length, xs)...)
Expand Down
Loading

0 comments on commit abc477e

Please sign in to comment.